Am I correct that you are trying to do the following:
1. The user enters numbers
2. You read in the numbers as strings and convert them to int
3. You calculate the sum of all ints
?
Perhaps you could try something like this:
Code:
stop = 0;
while (stop != 1)
{
scanf ("%s",temp_array);
if (strcmp (temp_array, "stop") == 0)
{
stop = 1;
}
else
{
total = atoi (temp_array);
sum = sum+total;
}
}
printf("the sum of these numbers is %d\n", sum);
The user enters numbers. If the user enters the word stop, then the loop ends. I've not tested this and probably there are better solutions, but you can give it a try.
The point where it is all about in my example is that you should introduce a check variable.