c++ - what is the error in that code? -


what error in code ??!!

hint : sp_to_dash() function in following program prints dash each space in string argument. is, string "this test" printed "this-is-a-test".

#include <stdio.h>  void sp_to_dash( char *str);  int main(void) {       sp_to_dash("this test");    return 0;     }  void sp_to_dash( char *str)     {       while(*str) {       if(*str==' ' ) *str = '-';       printf("%c", *str);       str++;       }     } 

string literals not modifiable. change way:

int main(void) {    char str[] = "this test";   sp_to_dash(str);    return 0;     } 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -