TutoStudio

como-escrever-bons-codigos_exemplo3.2

Dec 21st, 2017
2,986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <string.h>
  2. [...]
  3. /*
  4.     Função para contar o tamanho da string
  5.  
  6.     char *string String a ter seu tamanho contado
  7.  
  8.     Retorno tamanho da string
  9. */
  10. int contarTamanho(char *string){
  11.     int tamanho=0;
  12.     int i=0;
  13.  
  14.     while(string[i]!='\0' && i < strlen(string)){
  15.         if(string[i]==' '){
  16.             string[i]='\0';
  17.         }
  18.         tamanho++;
  19.         i++;
  20.     }
  21.  
  22.     return tamanho;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment