I need to count characters from a file. But I get an error error C2660: 'getchar' : function does not take 1 arguments.

Im new to C please bare with me.
Thanks for your help.

#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"

int _tmain(int argc, _TCHAR* argv[])
{
int ch ;
int count = 0;

FILE *fin,*fout;
    fout = fopen("m:/cop1220/wordin.txt","w");
    fin = fopen("m:/cop1220/wordin.txt","r");


    //ch=getchar();
    //fscanf(fin,"%c",&ch);
    while ((ch = getchar(fin)) != EOF)


   count ++ ;

printf( "%d characters\n" , count ) ;



system("pause");

    return 0;
}

Try

int getc(FILE *stream);

I was writing and getting my input from the wrong file thus I was getting a return of -1. Anyway, I thank you to all that replied. Here is what I really did and I owe someone from another site a big thank you.

#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include "string.h"
#include "ctype.h"
#include "math.h"





int _tmain(int argc, _TCHAR* argv[])
{
int ch=0,chars=0;
int count1 = 1,spaces=0,tabs=0,lines=1,punct = 0, digits=0;

    FILE *fin,*fout;
    fout = fopen("e:/cop1220/final/wordout.txt","w");
    fin = fopen("e:/cop1220/final/wordin.txt","r");




     while ((ch = fgetc(fin)) != EOF)
     {          ++chars; 
                if (isdigit(ch)) ++digits;      
                if (ch == ' ') ++spaces; 
                if (ch == '\t') ++tabs; 
                if (ch == '\n') ++lines;
                if (ispunct(ch)) ++punct;


     }



        //printf("%d,%d,%d,%d,%d %d \n", chars, spaces, tabs, lines,digits,punct); 
        fprintf(fout,"Count of characters = %d\n",chars);
        fprintf(fout,"Count of digits = %d \n",digits); 
        fprintf(fout,"Count of spaces = %d \n",spaces);
        fprintf(fout,"Count of tabs = %d \n",tabs); 
        fprintf(fout,"Count of lines = %d \n",lines);
        fprintf(fout,"Count of punctuation = %d \n",punct);


system("pause");
return 0;

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.