# include & ltstdio.h & gt
int fun(const char* str){
int output = 0;
int neg = 0; //sign, negative number is neg 1, positive number is neg 0.
int digit = 0;
If (! Str) returns 0;
if(*str=='-'){
neg = 1;
str++;
}
while(*str){
Output * =10;
Output+= * str-'0';
str++;
}
Return negative? -output: output;
}
void main(){
char str[ 100]= { 0 };
while( 1){
scanf("%s ",str);
printf("%d\n ",fun(str));
}
}
Output:
- 123456
- 123456
987654
987654