填空题

请补充函数proc(),该函数的功能是:把从主函数中输入的由数字字符组成的字符串转换成一个无符号长整数,并且逆序输出。结果由函数返回。例如,输入:1234567,结果输出:7654321。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
unsigned long proc(char*str)
{
unsigned long t=0;
int k;
int i=0;
i=strlen(str);
for(______; i>=0; i--)
{
k=______;
t=______;
}
return t;
}

void main()
{
char str[8];
system("CLS");
printf("Enter a string made up of "0"to "9" digital character: \n");
gets(str);
printf("The string is: %s\n", str);
if(strlen(str)>8)
printf("The string is too long!");
else
printf("The result: %lu\n",
proc(str));
}

【参考答案】

--i str[i]="0" t*10+k[解析] 由函数proc()可知,变量i首先被赋值为字符串str的长度,fo......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)