*****如何将字符串变量转化为整型变量

yunhaitian 2001-09-25 04:44:06
char a[]="50";
现在我想在字符串变量a在循环中每次增1,如何做到?请各位大虾指点一二
...全文
107 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jkaikai 2001-09-25
  • 打赏
  • 举报
回复
sprintf(a,"%d",++atoi(a))
yhp 2001-09-25
  • 打赏
  • 举报
回复
#include <stdlib.h>
#include <iostream.h>
void main()
{
int i;
char a[]={50};
for(i=50;i<100;i++)
{
int b=i;
itoa(b,a,10);
cout<<"The Current a[] is :"<<a<<endl;
}
}
djhdu 2001-09-25
  • 打赏
  • 举报
回复
sprintf(a,"%d",atoi(a)+1)
the_lion 2001-09-25
  • 打赏
  • 举报
回复
#include <stdlib.h>


int i;
char a[]="50";
int urnumber=100;//just a presumption
for(i=50;i<100;i++)
{
int b=i;
a=_itoa(b,a,10);//10 is the Base_of_Value
cout<<"The current value of a[] is:"<<a<<endl;
}
SCUM 2001-09-25
  • 打赏
  • 举报
回复
比较标准的方法:

short count;
char count_str[]="00000";

...
count++;
...
itoa( count, count_str, 10 );
...
.............




rusan 2001-09-25
  • 打赏
  • 举报
回复
int b=0;
...
b = atoi(a);
b++;
a = itoa(b);
...
yunhaitian 2001-09-25
  • 打赏
  • 举报
回复
急需帮助,诸位帮帮忙呀

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧