The logic of your code is to start from the high bit, then multiply by 10 and then accumulate. The idea is okay, but the code is wrong. 1: Do not use commas in the conditional part of the for statement. That is a comma expression, and only the rightmost m>=0 works. 2: The prototype of the pow function is double type. What you want is an integer type. If a strong transformation occurs in the middle, there will be errors. For example, if you enter "100000".
The simplest way is to write a pow function yourself to replace the library function.
The following is changed exactly according to your code:
#include
#include
#include
long pow2(int n,int m)
{
int i;
long sum =1;
for(i=0;i sum*=n; return sum; } long fun(char *s) { int i,n,m; long sum=0; n=strlen(s); m=n-1; for(i=0;i sum+=(s[i]-'0')*pow2(10,m); return sum; } p> int main() { printf("Convert the string "2345210" into a numerical value =%ld\n", fun("2345210")); printf("Convert the string "10000000" into a numerical value =%ld\n", fun("10000000")); return 0; }