28 lines
558 B
C
28 lines
558 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
int main(void) {
|
|
|
|
char str[100];
|
|
|
|
printf("Digite a sua frase: ");
|
|
fgets(str, 100, stdin);
|
|
|
|
str[strcspn(str, "\n")] = '\0';
|
|
|
|
int spaces = 0;
|
|
for (int i = 0; i < strlen(str); i++) {
|
|
if (str[i] == ' ') {
|
|
spaces++;
|
|
}
|
|
}
|
|
|
|
printf("O número total de caracteres são: %zu\n", strlen(str));
|
|
printf("O número de espaços são: %d\n", spaces);
|
|
printf("O primeiro caracter é \"%c\" e o último é \"%c\"\n", str[0],
|
|
str[strlen(str) - 2]);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|