Given a string. In the line, replace the semicolon with a colon.

There is a code:

# include <stdio.h> void main () { char s [30], sl [30]; int i,n = 0, k = 0; printf ("vvedite stroku: "); gets (s); for (i=0; i<strlen(s); i++){ if (s[i]==';'); } getch(); } 

What do I need to add to be replaced by a colon?

    1 answer 1

     if (s[i]==';') s[i]=':'; 
    • not working ( - Timi
    • one
      How to check? - chernomyrdin
    • Well, I took it and spent it .. - Timi
    • one
      puts (s); before getch () tried? - avp
    • 2
      I also checked, and it works for me: 1 #include <string.h> 2 #include <stdio.h> 3 main () {4 char s [30], sl [30]; 5 int i, n = 0, k = 0; 6 7 printf ("vvedite stroku:"); 8 gets (s); 9 for (i = 0; i <strlen (s); i ++) {10 if (s [i] == ';') s [i] = ':'; 11} 12 getchar (); 13} (gdb) b 12 Breakpoint 1 at 0x80484db: file 64543.c, line 12. (gdb) r Starting program: ./64543 vvedite stroku: abc; def Breakpoint 1, main () at 64543.c: 12 12 getchar (); (gdb) x / ss 0xbffff4c6: "abc: def" (gdb) _ - chernomyrdin