I started writing C code, and I needed a function toupperin my code, so I added it to the header file ctype.hto include it.
Suddenly, I cannot start my program because I keep getting an error redefinition of mainfrom my compiler.
Before adding a header ctype.h, and even if I get rid of the header file ctype.h, the program will start. What should I do to fix this?
#include <stdio.h>
#include <ctype.h>
#define NAMESPACE 20
int main (void)
{
char first_name[NAMESPACE], middle_name[NAMESPACE], last_name[NAMESPACE];
printf ("Please enter your first, middle and last name.\n");
scanf ("%s", first_name);
scanf("%s", middle_name);
scanf ("%s", last_name);
printf ("%s %0.1s %s", first_name, middle_name, last_name);
return 0;
}
[error] redefinition of "int main()":
Here is the code saved as the ctype.h header file in my C ++ DEV,
#include<stdio.h>
#include<conio.h>
int main (void)
{
char ch[]="I AM AN IDIOT.";
char c='A';
int i=0;
while(c)
{
c=getch();
printf("%c\a",ch[i]);
i++;
if(i==14)
{
printf(" "); i=0;
}
}
}
source
share