|
I mean that the function is not complete!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
It's a global function ? I don't know what you're trying to do, I presume you're trying to get the different parts of the filepath, i.e. seperate c:\my documents\my code\project1 into
c:\
my documents
my code
project1 ?
casting a char to a char * is not going to work, you need instead to do this
int len = strlen(&cPath);
This returns the address of the variable, (char*)cPath takes the value of cPath and assumes it is the address of a char array.
Overall, unless this is for an assignment, this is an ugly way of doing things. If you're not using MFC, your code would be a lot prettier if you use std::string. If you are using MFC, CString is another alternative.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
I just realised something else that should have been screamingly obvious to me - cPath is a deep copy of one char, it no longer points to the char array that it did in the calling function. You need to pass it in as a char* if you want access to the entire string instead of a copy of the one character.
It's late - I'm going to bed
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
cPath needs to be a pointer
declare your function like this:
int GetFileName(const char* cPath, char* pFileName);
OR
int GetFileName(LPCSTR cPath, LPSTR pFileName)
By the way, pFileName was never used in your function
- Dirty hands lead to important discovery...
|
|
|
|
|
I tried it and it seems to work..
char* tst = "hkjsdh\\ks\\dj\\sdsdsd\\sfssf\\sfsfs";
for (int i=0; tst[i]; i++)
{
if (tst[i] == '\\')
printf("[backslash]");
else
printf("%c", tst[i]);
}
I suppose the bug is somewhere else in your program?
/moliate
|
|
|
|
|
Okay man, now I'm realy stucked...
Let's say that I have a path to a file: "C:\Program\MyApp\tehexe.exe"
My function's (GetFileName(...)) main thing is to return the file name (theexe.exe) from that path.
But can't get it to work!
You have the code for that function in some of my messages here... help me with it!!!!!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Try this code out :-
char *p=abc;
while(strchr(p,'\\'))
{
p=strchr(p,'\\');
p++;
}
MessageBox(p);
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Are you required to write this yourself? If not, then use PathFindFileName() in shlwapi.dll. Otherwise, use strrchr() to find the last backslash.
char* pLastBkslash = strrchr ( szPathName, '\\' );
char* pFilename;
if ( NULL != pLastBkslash )
pFilename = pLastBkslash + 1;
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Michael Dunn wrote:
char* pLastBkslash = strrchr ( szPathName, '\\' );
That assumes that there is only one slash???
Or did it implicitly imply that the guy has to repeat that till he gets the last backslash?
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I used strrchr (notice the extra 'r' meaning "from the right") which finds the last occurrence of a character.
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Michael Dunn wrote:
I used strrchr (notice the extra 'r' meaning "from the right") which finds the last occurrence of a character.
Oops! Sorry Mike.
I never use that one. Donno why!
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
If i'm clocking code speed using QueryPerfomanceCOunter()
would it be more accurate if if set the current process/thread to a highest priority...?
Windows time slicing gives so much exec time to each process higer the priority = more time...?
This would mean less likely an interuption correct...?
Thanx!
p.s.I just d/l 34 Mb file in less than 3 minutes Shaw cable...Incredible...
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Take a look at the CPUTest article, it's related to your question. Most of the people tried it said it's better at real time priority. Just make sure you set the priority back to normal after the loop you want to clock
|
|
|
|
|
I want my mainframe has fixed size and user
can't resize it,what code shouid I add to
CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
I would figure
cs.x = FIXED_SIZE;
cs.y = FIXED_SIZE;
Although i dunno if this is enough...I'm thinking you'd probably control fixed sizes in OnSize.
Maybe returning false in PreCreateWindow would work, i dunno i'm too lazy to try it out first...
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
HockeyDude wrote:
i dunno if this is enough
Nope. Not enough.
He has to remove the WS_THICKFRAME style.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Sorry man I must correct myself.
I thought you were after only resize to a fixed size then hault.
But if all you want is a fixed size...
cs.cx = FIXED;
cs.cy = FIXED;
cs.style = WS_DLGFRAME;
However you could probably use Onresize to control this agin, but it's unessecary..
Ciao!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
FIXED or FIXED_SIZE are undeclared identifier,and compiler return error.
And there is one problem with "cs.style = WS_DLGFRAME;"
,the minimize,close buttons(I mean system menu) disappear?
thanks
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
Mazdak wrote:
FIXED or FIXED_SIZE are undeclared identifier,and compiler return error.
Oh God, someone help me.
Can't you tell that the variables being shown to you define the window size and need to be inserted by you ? He's showing you where to put the size you want.
For the caption you need to add the style bits for the system menu, etc. I don't recall them exactly, but it's something like WS_SYSMENU. Try msdn.microsoft.com to get a list of them. Actually, the better way to do it is take the old value, strip the style that you want to lose and then add the one you want. For exmaple, to remove WS_SYSMENU, you do this: myStyle &= (~WS_SYSMENU); I am presuming myStyle is a variable to which the old style has been stored.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Christian Graus wrote:
Oh God, someone help me.
I'll help you Christian
this was my code:
cs.style = WS_DLGFRAME;
cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
| WS_THICKFRAME | WS_MINIMIZEBOX | WS_SYSMENU;
cs.cx=cs.cy=600;
Here there is one problem and user can "RESIZE" the frame,of cource I have
system menu at this case,if I put WS_DLGFRAME at the end then I can't resize it but I don't have minimize and system menu.
At last I solved it with this:
cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
| WS_THICKFRAME ;
cs.cx=cs.cy=300;
cs.style = WS_DLGFRAME;
cs.style=WS_SYSMENU| WS_MINIMIZEBOX;
and everything is ok now
thanks toboth of you
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
Mazdak wrote:
cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
| WS_THICKFRAME ;
cs.cx=cs.cy=300;
cs.style = WS_DLGFRAME;
cs.style=WS_SYSMENU| WS_MINIMIZEBOX;
Now you DO realise that two of these four lines of code are useless, don't you ?
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Yeap,thats right,some times I become really stupid person
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
Mazdak wrote:
some times I become really stupid person
Everyone mazdak, everyone
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
FIXED_SIZE are just phantom variables.
sorry
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|