Why doesn't ANSI C use strrev
instead of creating such a big reverse function?
This code is showing me an error. Please correct it. What is the error. I am using Code::Blocks
Error message that I get:
c:\programfiles(x86)\codeblocks\mingw\bin..\lib\gcc\mingw32\4.7.1......\libmingw32.a(main.o):main.c:(.text.startup+0xa7)||undefined reference to `WinMain@16'|
#include <stdio.h>
#include <string.h>
#include <conio.h>
void reverse(int n, char s[])
{
int c,i, j;
for(i=0, j= strlen(s)-1; i<j; i++, j--){
c=s[i];
s[i]=s[j];
s[j]=c;
}
}
void itoa(int n, char s[])
{
int i=0 ,sign;
if((sign=n) < 0 )
n= -n;
do{
s[i++] = n%10 + '0';
}while(n /=10 >0);
if(sign <0)
s[i++] = '-';
s[i] = '\0';
reverse(n, s);
}
Your code has no entry point. You need to have a main
function, or WinMain
or something.
http://mingw-starter.blogspot.com/2008/02/mingw-sdl.html says
Also, don't forget to add the -mwindows flag, if your IDE doesn't add it automatically (in addition to whatever other libraries you want to link). If you don't put them in the right order, you'll get a linker error complaining about the missing symbol WinMain@16.