I've got a program where the user can add items to an array. All the sections of the array are error checked to make sure the user inputs numbers or letters when they are supposed to.
The problem I am having is with one field, the others are error checked and working fine. Its the price, it is defined as a float and read into the array differently so I am unsure where the problem is. Here is basically what I'm having trouble with:
With this code just now, it can detect when letters are entered and returns "Not Valid", but when numbers are entered, the line moves down and then nothing happens, it does not move onto the next section of code. Any idea?Code:float price; char tempstr[25]; int check(char tempstr[25]) { int j, c=1; j = atoi(tempstr); if (j==0) { c = 0; } return c; } int main() { do{ cout << ("Enter Price: ") cin >> tempstr; if (check(tempstr)==0) { cout << "not valid"; } }while (check(tempstr) !=1); scanf("%f",&slist[numitems].price); }