Mar 21, 2013 at 10:12pm UTC
do u want to print map[i][j] or what exactly ?
Mar 21, 2013 at 10:14pm UTC
mapprinter is a 1d char array
which i print out in line 11
but it doesn't print the whole thing only the first row
map[][] is 2d char array where all the variables are being transfered to mapprinter
Mar 21, 2013 at 10:18pm UTC
can u give full explanation for ur problem !
Mar 21, 2013 at 10:20pm UTC
when i run the program only the first row of the map is printed
i want every row to be printed
such as if the map is
00000
00000
00000
00000
00000
then mapprinter only prints
00000
Last edited on Mar 21, 2013 at 10:22pm UTC
Mar 21, 2013 at 10:22pm UTC
Why not print inside the loop itself?
1 2 3 4 5 6 7 8
for i
{
for j
{
std::cout << map[i][j];
}
std::cout << std::endl;
}
(obviously pseudo code)
Last edited on Mar 21, 2013 at 10:22pm UTC
Mar 21, 2013 at 10:23pm UTC
I'm trying to help but still I don't what the problem is all about
give me the problem maybe I can give u a HINT !
Mar 21, 2013 at 10:25pm UTC
LB its slower
pureevil:
i edited my last comment if you want more tell me
Mar 21, 2013 at 10:33pm UTC
what do u mean by this
mapprinter[(xmapsize+1)*(i+1)]='\n' ;
Mar 21, 2013 at 10:35pm UTC
to have it
00000\n
00000\n
00000\n
00000\n
00000\n
basicly to have endline for each row
Mar 21, 2013 at 11:17pm UTC
if you do
char mapprinter[12]="0000000000\n"
cout << mapprinter << endl;
the whole thing gets printed
doing the conventional way like you did is 2 times slower
but you can only do this with 1d array with 2d array you get an error which is why i convert the map to a 1d array
but the results where not proper
Mar 22, 2013 at 1:20am UTC
managed to solve it with some testing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
for (int j=0;j<ymapsize;j++)
{
for (int i=0;i<xmapsize;i++)
{
mapprinter[i+xmapsize*j+j]=map[j][i];
}
}
for (int i=1; i<=ymapsize; i++)
{
mapprinter[(xmapsize+1)*i-1]=10;
}
system("cls" );
cout << mapprinter;
Last edited on Mar 22, 2013 at 1:37am UTC