问答题
请编写一个函数proc(),它的功能是将一个数字字符书转换为一个整数(不得调用C语言提供的将字符串转为整数的函数)。
例如,若输入字符串“1234”,则函数把它转换为整数值1234。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
#include<string.h>
long proc(char*p)
{
}
void main()
{
char str[6];
long n;
printf("Enter a string:/n");
gets(str);
n=proc(str);
printf("%1d/n", n);
}