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

6th Oct 2018, 5:57 PM
Tuyen Pham
Tuyen Pham - avatar
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; }
6th Oct 2018, 7:48 PM
blACk sh4d0w
blACk sh4d0w - avatar