0
Can not run the sum value at the end (C program)
Write a function called convert StrtoInt that inputs four strings that represent integers, converts the strings to integers, sums the values and prints the total of the four values. Can someone help me to fix this code below since I can not run but I dont know what wrong with this. Thanks! https://code.sololearn.com/cAh4eC5g3q7x/#c
1 Answer
+ 9
If you want to convert Numeric string to Integer then here's the code below
#include <stdio.h>
#include <stdlib.h>
int main() {
char stringValue[80];
fgets(stringValue, 80, stdin);
printf("Numeric string entered: %s\n", stringValue);
char *ptr;
long int num = strtol(stringValue, &ptr, 10);
printf("Converted Numeric string to Integer: %ld\n", num);
return 0;
}