Quote Originally Posted by chibicitiberiu View Post
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?
You assumed that you did know how much memory by doing this:
Code:
for (i=lastslash;i<=strlen(pat);i++)
	filename[i-lastslash]=pat[i];
So how big were you expecting the filename string to be in the code above? Whatever that is, you need to create or have access to a buffer of that size first before this code is invoked.

Once you know that, then you use new[] and delete[] to allocate and deallocate memory. But as JohnW pointed out, it would be much worth your while to write a string class and use that instead. But that requires you know how to use dynamic allocation (new[]/delete[]).

Regards,

Paul McKenzie