What is wrong with this program?
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void count();
void main()
{
char c[100];
cout<<"Enter a string upto 99 characters(spaces included):"<<endl;
gets(c);
count(c);
getch();
}
void count(char s[])
{
int words=0, sentences=0;
for(int i=0;s[i]!='\0';i++)
{
if(s[i]==' ')
words++;
else
if(s[i]=='?' || s[i]=='.' || s[i]=='!')
sentences++;
}
cout<<"The number of words you entered is/are:"<<words+1<<endl;
cout<<"The number of sentences you entered is/are:"<<sentences<<endl;
} The thing is, when I don't create a prototype of count and straightaway define it before void main() my program runs, but it gives error in this program that "extra parameter in call to count()"
BUT WHAT TO DO THEN?
You have to create a prototype before your main function.You can't call someone who doesn't exist this is the thing here. You have to create the function before you call it. You can go without writing the prototype , if you declare your whole count function before your main function.