
April 5th, 2004, 09:19 PM
|
|
Registered User
|
|
Join Date: Apr 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
C++ problem with strings
I have a function to get the filename for opening which returns a char *.
char * MyGetOpenFileName(void)
In that function, I have "char szFile[MAX_PATH]" which I use with the GetOpenFileName function from windows.
When I trace the program I can see that szFile gets the entire correct filename and path, however, when I have "char *FN = MyGetOpenFileName();" the string FN only has the first 50 or so characters, then becomes gibberish. This happens whether FN is a char * or a char[MAX_PATH]. Does anyone have any idea what's wrong?
Also, maybe someone can clue me in on all the differences between char *, char [x], and char * = new char[x], and when to use "delete" or give me a link to where they are explained? (In my comp-sci class I only learned how to use the "apstring" class which doesn't work for a lot of windows functions.)
|