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) = '-';
}
}
}
void Exercise4(){
char* x = "the cat in the hat";
char* temp = x;
while((*temp)!='\0'){
if((*temp)==' '){
(*temp) = '-';
}
}
}