Q
questions?
What's wrong with the following sudo-code?
******************************
# include <stdio.h>
# include <string.h>
char *test="I am the string you testing on";
int main(){
char *point;
point=test;
while(*point !='\0'){
printf("%c\n",*point);
point++;
if(*point=='s')
*point='\0';
}
}
*****************************
I want to step out of the while loop once I met 's'.
However, when I got to *point='\0';
I have a segmentation error. I know there are better ways. I am just
curious about the reason.
Thanks
******************************
# include <stdio.h>
# include <string.h>
char *test="I am the string you testing on";
int main(){
char *point;
point=test;
while(*point !='\0'){
printf("%c\n",*point);
point++;
if(*point=='s')
*point='\0';
}
}
*****************************
I want to step out of the while loop once I met 's'.
However, when I got to *point='\0';
I have a segmentation error. I know there are better ways. I am just
curious about the reason.
Thanks