My program is supposed to read from a file to check number of words sentences ETC. It does this so far until I move the code into separate functions. It gives me the error that is in the topic title. Any ideas??
Code:
void findFile (char filename[], FILE *fp){
while (1){
char filename[100];
puts("Enter the name of the file to open");
scanf("%s", &filename);
fp=fopen(filename, "r");
if (fp == 0)
{
printf("\n\n%s file name not found!\n\n", filename);
}
else
{
puts("File successfully opened");
break;
}
}//End while loop
}//end function
/*************************Character counter function*************************************
Purpose: To count number of characters in a file
Parameters:
Return: none
Input:
Output:
***********************************************************************************/
void countChar (int charCount, int ch, FILE *fp)
{
while (1) {
ch = fgetc(fp);
++charCount;
if (ch == -1)
break;
}
ch = 0;
printf("\nNumber of characters: %i\n", charCount);
}
void wordCount (char i, int wCount, FILE *fp)
{
while((i = getc(fp)) != EOF)
{
if ((i = getc(fp)) == ' ')
++wCount;
}
printf("Number of words: %i\n", wCount);
}