我想从输入字符串中排序整数和字符串。从C++中的输入字符串中分隔字符串和int字符串
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
int main(){
char x[10];
int y;
printf("string: ");
scanf("%s",x);
y=atoi(x);
printf("\n %d", y);
getchar();
getchar(); }
假设输入是123abc1 使用的atoi我可以从输入字符串中提取123,我现在的问题是我如何提取ABC1?
我想将abc1存储在单独的字符变量上。
输入:123abc1 输出:X = 123,一些char变量= ABC1
我明白任何帮助。
我觉得应该是'atoi'而不是'itoa' – phoxis
@phoxis:你说得对,我让他们倒退。谢谢,修复。 –