Advertisement
Hardware

Exercício 6 - Strings

Nov 16th, 2011
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. main()
  5. {
  6.       char txt[50];
  7.       int n,i;
  8.       n=0;
  9.       printf("Digite uma frase qualquer:");
  10.       gets(txt);
  11.       for(i=0; txt[i] != '\0'; i++)
  12.       {
  13.                if(txt[i] == ' ')
  14.                       n++;
  15.       }
  16.       printf("Espacos contados: %d\n",n);
  17.       system("Pause");
  18. }            
  19.  
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement