What is following will surely appear very simple for c coders but I am coding a small program to modelize some game called gomoku. For the user, you have to enter an integer N wich corresponds to a ‘N times N’ square which consists of ‘N times N’ integers.
So the code is runnig quite well but I have some simple question : when I enter the ‘N times N’ integers, I made some
int N;
scanf("%d",&N);
char c[N][N];
while (i<N){
scanf("%s\n",&c[i]);
i++;
}
then I converted the char to int for each c[i] to make some computation involving c[i][j], which is quite unnatural. But if I had to declare int c[N][N], it would be impossible to retrive the same integers c[i][j] like those I inputed when the while-loop is running.
Does anyone has an idea to declare int c[N][N], inputing integers, and then computing the same when computing with integers c[i][j] ?
Best,
Newben
You don’t have to read char and then convert it to int. You can just simply read integeres:
And are you sure that you want to read just N integers? Not NN for whole array? In case you want to read NN objects to array, code should look like this: