|
Actually I don't have a code. I asked this based on MSDN example. I try it coding and let you know.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: Then gives ASSERT the application
what was your string?
|
|
|
|
|
You mean the CString which I used. It's like this, a path of a file.
F:\Resources\Files\G00166_003_01.txt
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: What is your comments.
Your code is inefficient, and makes many assumptions.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Check the PathStripPath() function
|
|
|
|
|
Thanks pal. But I feel that ReversFind() more easy, because I can use Mid() to extract any sub-string from the file name.
Thanks again.
I appreciate your help all the time...
Eranga
|
|
|
|
|
I'd strongly recommend using the ShellAPI command that David pointed you to.
What about
c:file.txt?
or all sorts of strange notations for filenames you will hardly ever use, but the shell team have handled for you?
Iain.
|
|
|
|
|
Or what about those that are named file.jpg.exe on machines with "Hide extensions for known file types" turned off? The possibilities are not endless, but there are several of them to consider when rolling your own implementation.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Some people just like that thunking feeling they experience as they keep banging their head upon the wall ...
I can't wait to see what turds float to the surface the moment a customer passes a network file path into that garbled up code!
I also like the code examples you come across that assume the 'path' starts after the semicolon.
Oh, wait the path "\\Dev\Link\Shared\MyFile.Txt" does not have a semicolon, how can this be
|
|
|
|
|
How about PathFindFileName in shlwapi.dll?
Pax Domini sit semper vobiscum
|
|
|
|
|
Thanks pal. But I think dealing with ReversFind() is so easy.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Does anyone know of any open-source code that will allow me to parse a C++ header file for all the class method signatures?
---
Yours Truly, The One and Only!
web: devmentor.org
Design, Code, Test, Deploy
|
|
|
|
|
Can you more explain about parsing a header file,please?
|
|
|
|
|
i am looking for simple code that will give me a list of all the class method signatures. i want to use these signatures for a tool to generate mock classes for a unit testing tool i have developed.
---
Yours Truly, The One and Only!
web: devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
What part of "parse a C++ header file for all the class method signatures" is troubling you? That's fairly self-explanatory, yes?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yeah I see.
BTW(I saw your signature they are nice sentences).
|
|
|
|
|
|
i was just thinking about this project!
i wonder if they have a few simple classes i can use to get a parse tree of only the method signature? ... i was looking for something more simple, don't got the energy to dive into larger projects and start ripping out what i need
possibly i can ask the developers to point me to the files i need.
thanks
---
Yours Truly, The One and Only!
web: devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
just a guess, but what are you trying to accomplish here ?
forget this, i've just seen your reply[^] to Hamid.
|
|
|
|
|
DevMentor.org wrote: i was looking for something more simple
Unfortunately, this is not a simple problem.The parser has to be able to handle everything that the CPP language can throw at it, and has to start with trigraph conversion and pre-processing.
If all you need is a tool to fish methods out of classes, something simpler may do. Kernighan and Ritchie give an excelent example of a function declaration parser in their book which you can possibly expand upon for CPP. But, then again, you need to know the names of the types. They are often declared in previously included headers. Maybe hard code in a basic symbol table?
Regards and success
Bram van Kampen
|
|
|
|
|
Thanks Bran for your reply.
I have found a simply tool that someone from the Doxygen-Develop mailing list said I could use, it's called gcc-xml and designed for tool developers like me who don't want to read the "Red Dragon" book on parsing
---
Yours Truly, The One and Only!
web: devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
I am currently trying to create a program to find all possibilities for placing 5 queens and 5 knights on an 8x8 board in such a way nothing will attack anything else. There are 16 possible solutions. My problem i am encountering, is when placing queens. It is not generating all possibilities. I believe it is just taking the first instance it finds and going with that rather than examining the rest of the row for possible solutions. Here is what I have, if you could possibly help it would be greatly appreciated.
#include <iostream>
#include <string>
using namespace std;
class QueenKnight
{
public:
QueenKnight()
{
queens = 0;
knight = 0;
row = 8;
column = 8;
count = 0;
for(int i= 0; i<row; i++)
="" {
="" for(int="" j="0;" j<column;="" j++)
="" board[i][j]="." ;
="" }
=""
="" void="" updateboardq(int="" r,="" int="" c)
="" i="0;" i<row;="" if(i="=" r)
="" if(j="" !="c)
" if(="" (i-j)="=" (r-c)="" )
="" j!="c)
" (i+j)="=" (r+c)="" placequeen(int="" startr,="" startc)
="" if(board[startr][startc]="=" ".")
="" board[startr][startc]="Q" updateboardq(startr,="" startc);
="" if(board[i][j]="" if(queens="" <="" 5)
="" updateboardq(i,j);
="" queens++;
="" }
="" countfree()
="" 8;="" j<8;="" count++;
="" return="" count;
=""
="" displayboard()
="" i<="" row;="" cout="" <<board[i][j]="" <<"="" ";
="" <<endl;
="" bool="" checkknight(int="" i,int="" j)="" returns="" false="" if="" position="" is="" not="" acceptable
="" if((i+2)="" &&="" (j-1)="">=0)
{
if(board[(i+2)][(j-1)] == "Q" || board[(i+2)][(j-1)] == "K")
{
return false;
}
}
if((i+2) <= 7 && (j+1) <=7)
{
if(board[(i+2)][(j+1)] == "Q" || board[(i+2)][(j+1)] == "K")
{
return false;
}
}
if((i-2) >= 0 && (j-1) >=0)
{
if(board[(i-2)][(j-1)] == "Q" || board[(i-2)][(j-1)] == "K")
{
return false;
}
}
if((i-2) >= 0 && (j+1) <= 7)
{
if(board[(i-2)][(j+1)] == "Q" || board[(i-2)][(j+1)] == "K")
{
return false;
}
}
if((i+1) <= 7 && (j-2) >=0)
{
if(board[(i+1)][(j-2)] == "Q" || board[(i+1)][(j-2)] == "K")
{
return false;
}
}
if((i+1) <= 7 && (j+2) <=7)
{
if(board[(i+1)][(j+2)] == "Q" || board[(i+1)][(j+2)] == "K")
{
return false;
}
}
if((i-1) >= 0 && (j-2) >=0)
{
if(board[(i-1)][(j-2)] == "Q" || board[(i-1)][(j-2)] == "K")
{
return false;
}
}
if((i-1) >= 0 && (j+2) <= 7)
{
if(board[(i-1)][(j+2)] == "Q" || board[(i-1)][(j+2)] == "K")
{
return false;
}
}
return true;
}
void placeKnight()
{
for(int i=0; i<8; i++)
{
for(int j=0; j<8; j++)
{
if(board[i][j] == ".")
{
if(checkKnight(i,j))
{
board[i][j] = "K";
knight++;
}
}
}
}
}
int knightCount()
{
return knight;
}
private:
int row;
int queens;
int column;
string board[8][8];
int count;
int knight;
};
int main()
{
int displays = 0;
for(int k=0; k<64; k++)
{
QueenKnight example;
example.placeQueen((k/8), (k % 8));
if(example.countFree() > 4)
{
example.placeKnight();
//cout <<"display: "<<displays<< endl;
="" if(example.knightcount()=""> 2)
// {
example.displayBoard();
cout <
|
|
|
|
|
Hi,
I did not study your code in detail, but have two remarks.
your code would be (more) readable when you:
- show it inside PRE tags (they preserve formatting, in particular indentation)
- (if possible) put opening brackets on the right of the previous line (which most
people don't do, I prefer it since it allows for more useful code lines per screen)
your code would be a lot simpler if you would use a one-dimensional board[64] array
(i.e. concatenating the eight rows) it would avoid a lot of for loops.
For attack checking, you would have to convert the linear index into a row/col pair
which is simply a divide/modulo 8 operation (two preprocessor macros can come in handy here).
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
can someone post a code on this forum that that takes a matrix converts it to upper triangular form prints the upper triangular form,
|
|
|
|