Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- char str[100];
- int i;
- int char_count=1;
- int word_count=0;
- int row_count=0;
- int main()
- {
- printf("Inserire del testo:\n");
- for(i=0; i<100; i++)
- {
- scanf("%c",&str[i]);
- char_count++;
- if(str[i]=='\n')
- {
- char_count--;
- }
- if(str[i]==' '&&str[i+1]!='\n'&&str[i-1]!=' ','\0')
- {
- word_count++;
- }
- if((row_count==0&&str[0]=='X')||(row_count!=0&&str[0]=='X'&&str[1]=='\n'))
- {
- exit(0);
- }
- if(str[i]=='\n')
- {
- break;
- }
- }
- row_count++;
- printf("\nNumero di caratteri: %d\n", char_count-1);
- printf("Numero di parole: %d\n", word_count);
- printf("Numero di righe: %d\n\n",row_count);
- main();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement