-2

I need to save a user input into a 2D array in a way where the user inputs something like '123456789' and I save that input into an array so that array[0][0] == 1, array[1][2] == 6 etc. Is there something like getchar() that I could use, but for numbers?

John Pace
  • 1
  • 2

1 Answers1

0

You can use getchar() itself, and convert it to integer using:

char c = getchar();
int arr[3][3];
arr[0][0] = c - '0';

Refer this stackoverflow answer.

Bharat S
  • 334
  • 1
  • 8