Created
November 21, 2017 11:39
-
-
Save unaipme/0975712470c8d7f223995970c748ee98 to your computer and use it in GitHub Desktop.
Hitzak kontatzen dituen programa, hitzen artean dauden hutsune kopurua kontuan hartuta
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int hitzakKontatu(char str[]); | |
int main(void) { | |
char str[256]; | |
printf("Sartu esaldi bat: "); | |
fgets(str, 256, stdin); | |
int hitzKop = hitzakKontatu(str); | |
printf("Esaldiak %d hitz ditu.\n", hitzKop); | |
printf("Sakatu intro bukatzeko..."); | |
getchar(); | |
return 0; | |
} | |
int hitzakKontatu(char str[]) { | |
int hitzak = 0, i; | |
char azkena = ' '; | |
for (i = 0; i<strlen(str); i++) { | |
if (str[i] == ' ' && azkena != ' ') { | |
hitzak++; | |
} | |
azkena = str[i]; | |
} | |
return hitzak; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment