[Solved] Splitting a string into integers
[ad_1] Since you are sure the string will contain digits, subtract each character from ‘0’ to get their numeric value. int sum = 0; fgets(str, sizeof str, stdin); char *s = &str; while(*s != ‘\0’) { sum += *(s++) – ‘0’; } printf(“the sum of the digits is: %d”, sum); [ad_2] solved Splitting a string … Read more