#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NUM 111
typedef int BOOL;
typedef enum { false,true } BOOL;
int my_strlen(char str[])
{
int i = 0;
while (str[i] != '\0')
{
++i;
}
return i;
}
int main()
{
char str[] = "\r \n \t -123";
int a = atoi(str);
printf("a = %d\n", a);
int b;
sscanf(str, "%d", &b);
printf("b = %d\n", b);
//整型转字符串
int num = -234;
char buf[100];
sprintf(buf, "%d", num);
printf("buf = %s\n", buf);
system("pause");
return 0;
}
c 整型和字符串直接的转换
最新推荐文章于 2024-02-01 10:29:51 发布