Advertisement
STANAANDREY

sb3 2 bac2020 t20

May 16th, 2022
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define NMAX 103
  4. #define SEP " "
  5. char s[NMAX], aux[NMAX];
  6.  
  7. int main() {
  8.     gets(s);
  9.  
  10.     char *token = strtok(s, SEP);
  11.     while (token) {
  12.         char *p = strchr(token, ',');
  13.         if (p) {
  14.             strncat(aux, token, strlen(token) - strlen(p));
  15.         } else {
  16.             strcat(aux, token);
  17.         }
  18.         strcat(aux, " ");
  19.         token = strtok(NULL, SEP);
  20.     }
  21.  
  22.     strcpy(s, aux);
  23.     puts(s);
  24.     return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement