I think i have some mixed up stuff in my program, maybe some c++ in there as well. Used alot of internet sites and maybe misunderstood something. Im trying to get this thing to count the number of lines words and characters in a file name. any help would be appreciated. Here is what i have
Code:
#include<stdio.h>
void chars(struct file ); /* function prototype*/
void words(struct file ); /*function prototype*/
void lines(struct file ); /*function prototype*/
struct file;
struct in;
int main ()
{
file *in;
char fNAME[15]; /*limits chars to 15 for input*/
printf("\nEnter the file name: ");
scanf ("%s",fNAME);
in=fopen(fNAME, "r"); /*opens file*/
if(in == NULL) /*checks for file opening*/
{
printf("\n Cannot find file %s.\n",fNAME);
exit(1)
}
chars(in);
words(in);
lines(in);
fclose(in); /*fclose closes a file*/
system("pause");
return 0;
}
void chars(file * fNAME) /*a pointer to a file*/
{
long ftell();
fseek(fNAME, OL, SEEK_END); /*for file positioning to the end of the file*/
printf("The number of characters in the file is: %d\n",ftell(fNAME));
return;
}
void words(filw * fNAME) /*a pointer to a file*/
{
long ftell();
fseek(fNAME, OL, SEEK_END);/*for file positioning to the end of the file*/
printf("The number of words in the file is: %d\n",ftell(fNAME));
return;
}
void lines(file * fNAME) /*a pointer to a file*/
{
long ftell();
fseek(fNAME, OL, SEEK_END); /*for file positioning to the end of the file*/
printf("The number of lines in the file is: %c\n",fNAME);
return;
}