Quote Originally Posted by Paul McKenzie View Post
Second, char* is not a string. You need to allocate memory and point the pointer to the beginning of this buffer. This simulates string handling, since there is no real "strings" in your version of C++ (which is very old). That's why this code is no good:
Code:
char* filename;

if (lastslash!=0) lastslash++;
for (i=lastslash;i<=strlen(pat);i++)
	filename[i-lastslash]=pat[i];
What buffer is "filename" pointing to? It's pointing to a random section of memory. You then attempt to write to this random memory, and who knows what will happen.

Regards,

Paul McKenzie
Than how do I do that? I don't really know how to allocate memory, i know very few information about pointers.
How do I know how much memory will this string need?