Quote:
Originally Posted by fakie_flip
I am using gcc main.c -o main
It compiles fine, but gets stuck in the loop. z never increments. I was using a for loop originally but had the same problem so I decided to try a while loop.
|
It is exactly as graemef said. You overwrite the value of z
because you write after the array.
Quote:
Originally Posted by fakie_flip
Code:
int z = 0;
while(z<MAX_INPUT) {
|
Even if you enlarge the array to 30 characters, this check is not correct.
You need to check the length of the string given (for example if i type
the number "50", you check 30 chars when you should check 2).
Quote:
Originally Posted by fakie_flip
Code:
int_num_arr[z] = atoi(&str_num_arr[z]);
|
You want to get only one digit, right ? If yes, then this won't work.
You can get the digit easily with
Code:
int_num_arr[z] = str_num_arr[z] - '0';