I was just playing around with it, it's not mean to be a serious program. The algorithm is the issue. All I want to do is move the person array, inside the world array, with each key stroke.
It is not importnat whether this is a serious program. The style of programming does depend on whether the prjgram is serious or not. This says that you can not program.
I do not understand why you are using four loops. In fact you need copy rows from person to world. All two-dimensional arrays are copied with two loops: one - for rows and other - for elements in a row.
@Vlad
Lay off. If you look closely to those 4 for loops you'd see that there are only 2 loops per array, the outer 2 for the world, the inner 2 for the person. He needs to re-think his logic.
@toomanystars
Perhaps if you tried thinking about printing things in layers (e.g. first the world, then the person) you might have more luck.
@Ikaron
@Vlad
Lay off. If you look closely to those 4 for loops you'd see that there are only 2 loops per array, the outer 2 for the world, the inner 2 for the person. He needs to re-think his logic.
It seems that you have the same level of mastering the programming as the author of the thread, There shall be only two loops for copying one two-dimensioanl array into another.
@ Vlad
I'm fully aware of that. Once again, he needs to re-think his logic, for if he does he and spends enough time on it he'll come to that realization himself. But not that you seem to actually care about that. You can take your "superiority" and shove it up your ass.
@ toomanystars
Feel free to send me a PM if you'd like me to help nudge you towards figuring out the problems with your program and get away from this thread.
I appreciate the contempt, and I total agree with you that I can't program. You will notice I never claimed otherwise. So, besides these obvious points, I am not sure what your point is, except maybe in some small way make yourself freel superior.
Sleep well tonight knowing your mastery of C++ is superior to an accountant who spends on average two hours a night working on his hobby.
@toomanystars: dont be disappointed because of cold replies from some cold person, there are knowledgable people in this forum( who believe learning is a continuous process and mastery is just an illusion), they will eagerly help u, and they are friendly.
The majority of the people here are great, I have no issue there. I can assure you that at my age someone being "cold" in an online forum does not concern me.
At first try to write stand-alone function that copies one two-dimensional array into another two dimensional array without using the variable that keeps the direction of pressed keys because such a function shall not depend on some other code.
To copy one row of a two-dimensionnal array into a row of other two dimensional array it is enough to use only one loop. There are several approaches.
For example
1 2 3 4 5 6
const size_t M = SomeValue;
const size_t N = OtherValue;
int a[M] = {};
int b[N];
for ( size_t i = 0; i < M; i++ ) b[i] = a[i];
Another way is to use pointters
for ( int *p = a, *q = b; p != a + M; ++p, ++q ) *q = *p;
The same can be done with using standard algorithm std::copy
1 2 3 4 5
#include <iterator>
#include <algorithm>
....
std::copy( std::begin( a ), std::end( a ), std::begin( b ) );
where std::begin( a ) is equivalent to a (that is to the pointer to the first element of array a ) and std::end(a ) is equivalent to a + M.
So to copy not only a row but a whole two-dimensional array into another two-dimensional array you need only to add an outer loop for rows of arrays
I will give this a shot tonight after work, see what I come up with. It however seems to make more sense than going 4 loop deep, which was really confusing.