可能的重复项:
How to convert a single char into an int
有人能告诉我如何将char
转换为int
吗?
char c[]={'1',':','3'};
int i=int(c[0]);
printf("%d",i);
当我尝试这个的时候,它给出了49。
发布于 2009-05-15 12:50:40
标准函数atoi()
很可能会执行您想要的操作。
使用“atoi”的简单示例:
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int useconds = atoi(argv[1]);
usleep(useconds);
}
https://stackoverflow.com/questions/868496
复制相似问题