Click to See Complete Forum and Search --> : whats wrong with this?


waris
12-07-2004, 12:06 AM
can someone take a look at this c code and let me know wats wrong with it. Its soppuse to run through the string and replace the spaces with a -. The code seems to work fine until it finds the space and i try to replace it with a -. At this point It breaks down. I down know why its doing this...Is there a limit on wat i am allowed to do char* .

void Exercise4(){


char* x = "the cat in the hat";

char* temp = x;

while((*temp)!='\0'){

if((*temp)==' '){

(*temp) = '-';

}

}

}

serz
12-07-2004, 12:45 AM
Locking this one..

Could you please repost this with a proper subject? "what's wrong with this?" tell us nothing about your problem/question.

Community Help Posting Guidelines (http://www.justlinux.com/forum/showthread.php?s=&threadid=91074)

Thank you for understanding.