Advertisement
Jordimario

attacca due stringhe con spazio

Mar 28th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define MAX 100
  5. int main()
  6. {
  7.     int i=0;
  8.     int j=0;
  9.     char stringa[MAX];
  10.     char spazio[MAX]=" ";
  11.     char stringa2[MAX];
  12.     printf("inserisci una stringa\n");
  13.     fflush(stdin);
  14.     gets(stringa);
  15.     printf("la stringa inserita e' %s\n",stringa);
  16.         fflush(stdin);
  17.     gets(stringa2);
  18.                 printf("la srtringa %s\n",stringa2);
  19. strcat(stringa,spazio);
  20. strcat(stringa,stringa2);
  21.     while(stringa[i]!='\0')
  22.     {
  23.         i++;
  24.     }
  25.  
  26.     printf("la srtringa %s e' lunga %d caratteri",stringa, i);
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement