Hi all, I've done this prog to get the last token in a string
es: /dir1/dir2/file.txt must return --> file.txt
I get several errors on assignments, what's wrong with it?
many thanks
int main() {
char *path;
char *filename;
path = (char*) malloc(sizeof(char) * 64);
strcpy(path, "/dir1/dir2/file.txt");
filename = get_filename(path);
printf("%s\n", filename);
return 0;
}
char* get_filename(char *path) {
char* filename;
filename = // calculate filename with strtok(), it works ok (printf checked)
return filename;
}