c - itoa 使用反向(字符串)代码显示错误

标签 c itoa

<分区>

为什么 ANSI C 不使用 strrev 而不是创建这么大的反向函数?

这段代码向我展示了一个错误。请更正。什么错误。我正在使用 Code::Blocks

我收到的错误信息:

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);
 }

最佳答案

您的代码没有入口点。您需要有一个 main 函数,或者 WinMain 之类的。

http://mingw-starter.blogspot.com/2008/02/mingw-sdl.html

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.

关于c - itoa 使用反向(字符串)代码显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24295020/

相关文章:

c - 数组与常量指针一样还是有其他区别?

c - 在 C 中制作 shell,但无法让 chdir 工作?

c - 我自己的随机数生成器

c - 如何从 PostgreSQL 的 libpq 中删除 PGPing 结果?

c++ - itoa 替换为 std::to_string 如何

c - uint64_t 到数组 - C 语言

c++ - 使用 Arduino 上的 atoi 和 itoa 从 int 转换为字节数组然后返回 int 进行传输

c - 如何将一串字符插入到 char* 的中间并将所有字符向右移动而不删除任何内容

c - 串联+ itoa的问题