hey all, figured I'd post this in the C board because I'd probably get a better result, since it seems to be a problem caused by a C standard library function declared in string.h.
first let me show you some declarations:
name is declared as a member of a pfile struct, which is a pointer to a struct that is declared globally. name is declared as:
Code:
char name[_MAX_FNAME];
p is declared as a local variable inside of the function that I am attempting this in as:
now here is what I am attempting:
Code:
p = PathFindFileName(szListData[0][0]);
strcpy(pfile->name, p);
MessageBox(NULL, pfile->name, NULL, MB_OK);
yes, there are Win32 APIs in there, but for now, just pretend they are functions written by myself to perform the actions made obvious by their names. they are not the problem. the problem is the strcpy statement.
when I compile this code, it compiles 0 errors 0 warnings, yet when I execute it, I get an error from Windows saying that the application needs to be closed.
yet when I compile and execute this code:
Code:
p = PathFindFileName(szListData[0][0]);
MessageBox(NULL, p, NULL, MB_OK);
it prints the filename successfully without any problems (hence how I know it is not the APIs causing the problem).
the problem seems to lie in the strcpy statement, which I just can't understand. that code looks 100% legal to me, along with everybody else I have showed it to.
could anyone please tell me what the heck could be happening here?
any help at all would be greatly appreciated. thank you in advance.