#include <iostream>
#include <stdio.h>
#include <queue>
usingnamespace std;
int main()
{
int t, n, cnt;
char bw[30][30], c;
scanf("%d",&t);
for (int i = 0; i < t; i++)
{
scanf("%d",&n);
for (int r = 0; r < n; r++)
{
for (int k = 0; k < n; k++)
{
scanf("%c", &c);
c = bw[r][k];
}
}
}
}
The problem is that it doesn't work for the last input case 4 which is:
4
....
....
####
####
If more clarification is needed please ask as this is really bugging me.
Your help is much appreciated :)
I solved it, it seems scanf has problems with 2D arrays so I used cin instead.
Tresky: The program terminates after the third row.
ats15: you're right, I just deleted c completely and instead of it I wrote
#include <iostream>
#include <stdio.h>
#include <queue>
usingnamespace std;
int main()
{
int t, n, cnt;
char bw[30][30], c;
scanf("%d",&t);
for (int i = 0; i < t; i++)
{
scanf("%d",&n);
for (int r = 0; r < n; r++)
{
for (int k = 0; k < n; k++)
{
scanf("%c", &bw[r][k]);
}
}
}
}