I have this code below that accepts up to 8 numbers and stores them in an array. I use a zero to stop taking numbers. I am trying to keep the zero from being stored in the array. Is there a way to do it?
Code:
printf("\nPlease enter up to 8 numbers to stop entering numbers enter zero\n");
printf("\n");
for (i=0;i<8;i++)
{
fgets(theNums[i],50, stdin);
j=strlen(theNums[i])-1;
theNums[i][j] = '\0';
if (theNums[i][0]=='0') /*exit if zero*/
break;
else
nums[i]=atoi(theNums[i]);
numberCount ++; /*count numbers being entered*/
}
printf("\n\n");