I think you're declaring that the variable remain constant or so, if you wanted to set it up as a pointer, the initialization would look like this:
char *str = "Hello";
I haven't written C in about 3 months, but I believe this is how you set it up. I'm not sure setting it to a pointer like that will work or not, so you might need to malloc before you assign value(s) to the string.
Main Topics
Browse All Topics





by: hienhienPosted on 2003-08-21 at 23:11:29ID: 9201040
because you are using a pointer ( *str)
you should use this line as well
char* str = strdup("Hello");
after that your program will no errors