sscanf与sprintf
str与int的互转
sscanf():str->int
用法:
sscanf(str,"%d",&n);
1
2
3
4
5
6
7
8
int main()
{
int n;
char str[100]="1223343";
sscanf(str,"%d",&n);//从左向右传值
printf("%d",n);
}1
1223343
sprintf():int->str
用法:
sprintf(str,"%d",&n);
1
2
3
4
5
6
7
8
int main()
{
int n=2333;
char str[100];
sprintf(str,"%d",n);//从右向左传值
printf("%s",str);
}1
2333