FranciscoSoccol

Lista 08 - Exercicio 07

Aug 10th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #define MAX 200
  4.  
  5. //prototipo
  6. int stringTamanho(char *s);
  7.  
  8. int main()
  9. {
  10.     char s[MAX];
  11.     printf("Digite a palavra: ");
  12.     gets(s);
  13.     printf("Tamanho da palavra: %d\n", stringTamanho(s));
  14.     return 0;
  15. }
  16.  
  17. int stringTamanho(char *s)
  18. {
  19.     int i=0;
  20.     while(*(s+i)){//*s aponta para a primeira letra , somando mais i, muda a letr
  21.         i++;}
  22.     return i;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment