Question: How could I create a conditional statement that prevents entering the fail state, and asks the user for new data when either the data is invalid or the data is not 1, 2, 3 OR 4 ?

```
int choice;

while ( !choice || choice != 1 || 2 || 3 || 4){
     cout << "Entry Invalid. Enter again: ";
     cin >> choice
}

```

For example, If the user enters 'f', then the fail state would be taken care of, and the program would ask for new data. And when they enter 5, the program would say "Not a valid number", and ask for new data.

Answer: 
Let's suppose your input `011R0` is stored in array `buf` then to print ASCII value of each character, you'll have to access each character and print it as if you are printing an integer:

```
  int i;
  while(buf[i])
   {
       printf("%d\n",buf[i]);
       ++i;
   }

```

By using indices `[i]` one can access each character if the string. Besides that have a look at this: [Why is “while ( !feof (file) )” always wrong?](https://stackoverflow.com/questions/5431941/why-is-while-feof-file-always-wrong)
*I thought printing out %c would give me the ASCII value ?* **No**, the format specifier `%c` prints equivalents `char` value, since `buf4`, `buf5`..etc are char array, so when you prints `*buf5` it prints first char of array & if you print `ascii` value of that, you have to subtract it from `48`(ASCII value of 0) if `*buf` contains digits(0 - 9). For e.g 

```
printf("%d\n",(*buf4)  - 48);  

```

Or

```
printf("%d\n",(*buf4)  - '0'); 

```

Also for this particular case its wstage of stack memory to declare five char array like `buf3`,`buf4`..`buf9`. you can use just one char array & do the operation. For e.g

```
int index = 0 ;
char buf[20]; /* lets say each word of file are length of 20 char, you can change it */
while (fscanf(fp,"%s",buf) != EOF) {
        while(buf[index] != '\0') {     
                if(buf[index] >= '0' && buf[index] <= '9') { /*or use isdigit() */
                        printf("%d",buf[index] - 48);
                }
                else { /* apart from 0,1,...9 */
                        printf("%d",buf[index]);
                }
                index++;
        }
        printf(" ");
        index = 0;
}

```

Also read why its wrong to use `feof()` [here](https://stackoverflow.com/questions/5431941/why-is-while-feof-file-always-wrong)