I wrote this program and am trying to simplifying by creating a character array. How can this be done please?
I found some help here
http://www.java2s.com/Code/C/Data-Type/Forloopachararrayusingpointer.htm
but couldn't really implement that in my program.
//inputs five strings representing integers, converts the strings to
//integers, sums the values and prints out the total
#include<stdio.h>
#include<stdlib.h>
int main ()
{
int i,a,b,c,d,e;
char word1[256],word2[256],word3[256],word4[256],word5[256];
printf("enter something \n");
fgets(word1,256,stdin);
printf("enter something \n");
fgets(word2,256,stdin);
printf("enter something \n");
fgets(word3,256,stdin);
printf("enter something \n");
fgets(word4,256,stdin);
printf("enter something \n");
fgets(word5,256,stdin);
a=atoi(word1);
b=atoi(word2);
c=atoi(word3);
d=atoi(word4);
e=atoi(word5);
i=a+b+c+d+e;
printf("Total value entered is %d\n\n",i);
return 0;
}