I was coding a program that can count space, new_line, and other characters in a paragraph, but it doesn't work. Please help me find errors in this system. :(
#include <stdio.h>
int main(void)
{
int space = 0;
int new_line = 0;
int others = 0;
int i;
char ch[100];
printf("Enter a string ending with # and press enter\n");
scanf("%s", &ch);
for(i=0 ; ch[i] != '#' ; i++)
{
if(ch[i] ==' ')
{
space++;
}
else if (ch[i] == '\n')
{
new_line++;
}
else
{
others++;
}
}
printf("The input includes %d spaces, %d new lines, and %d other characters.", space, new_line, others);
getch();
return 0;
}