2024-04-17 19:07:42 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2024-05-02 09:52:00 -04:00
|
|
|
// counting spaces, tabs and newlines
|
|
|
|
|
2024-04-17 19:07:42 -04:00
|
|
|
main()
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
int count_tabs = 0;
|
|
|
|
int count_newlines = 0;
|
|
|
|
int count_spaces = 0;
|
|
|
|
|
|
|
|
while ((c = getchar()) != EOF)
|
|
|
|
{
|
|
|
|
if (c == '\t')
|
|
|
|
++count_tabs;
|
|
|
|
if (c == '\n') {
|
|
|
|
++count_newlines;
|
|
|
|
printf("\n\ntabs: %d, spaces: %d, newlines: %d\n", count_tabs, count_spaces, count_newlines);
|
|
|
|
}
|
|
|
|
if (c == ' ')
|
|
|
|
++count_spaces;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\ntabs: %d, spaces: %d, newlines: %d\n", count_tabs, count_spaces, count_newlines);
|
|
|
|
}
|