Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int count(char *input)
  4. {
  5.     int counter = 0;
  6.     int i;
  7.    
  8.     // Durchlaufe bis zur Null-Terminierung
  9.     // (Wird von scanf drangehängt)
  10.     for (i = 0; input[i] != '\0'; ++i)
  11.         ++counter;
  12.        
  13.     return counter;
  14. }
  15.  
  16. int main()
  17. {
  18.    
  19.     // Maximal 19 (-1 wegen null Terminierung) erlaubt
  20.     char input[20];
  21.    
  22.     // Lese Benutzereingabe
  23.     scanf("%19s", input);
  24.  
  25.     // Gebe Anzahl aus  
  26.     printf("%d", count(input));
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement