Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to assign a numeric value in a string to an integer variable?
How to assign a numeric value in a string to an integer variable?
Stoj (char *a)

{

Static long integer b = 0;;

if (*(a)! ='\0') {

b = b * 10+(* a-48);

stoi(a+ 1);

}

Return (b);

}

Pass in a string, return the corresponding long integer value, and call the example:

// -

# include & ltstdio.h & gt

Stoj (char *a)

{

Static long integer b = 0;;

if (*(a)! ='\0') {

b = b * 10+(* a-48);

stoi(a+ 1);

}

Return (b);

}

int main()

{

char s[]= " 32700 ";

Long a;

a = stoi(s);

printf("%ld ",a);

Returns 0;

}

// -