My coding shows error when built and run.
The error shows multiple definition of 'main'.
Can someone help me what I did wrong here?

#include <stdio.h>
int main()
{
    FILE *fPtr;
    int c;
    fPtr=fopen("C:\\Question1.txt","r");
    c = getc(fPtr);
    while (c!=EOF)
    {
        putchar(c);
        c=getc(fPtr);
    }
    fclose(fPtr);
return 0;
}

Recommended Answers

All 3 Replies

You've got a function named main somewhere else as well. Perhaps you are compiling this code and some other code into the same program.

The program seems as correct. I cannot spot what went wrong. But try again after including the library function #include<conio.h> as well.

But try again after including the library function #include<conio.h> as well.

Not only will this not solve the problem, it also destroys code portability by requiring the compiler to support a non-standard library.

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.