Hello, i'm new to C++, I'm just learning basic C++ and am working on an exercise in which I'm involved in making a simple grid. And although I have a good knowledge concerning arrays and loops, some of the first things I learned about, I seem to be unable to get this grid to work properly. As far as I know the grid should work, however, when I test the program the console somes up with a blank screen when there should be a 7x10 grid. I've pasted samples of others work into the program to see if their code will show a grid and they do. I compare sample of code to what I have pasted, and I can't spot anything to different to seem significant. And now, after a little tweaking to make it work although it should, whenever I execute the program my pc sends an error message, and my program crashes. I'm absolutely clueless of what I've done wrong, I personally think there may be something wrong with the compiler itself which I am using. Here is the code I have typed up for this exercise, and I hope someone can help me with my trouble.
Well, for starters, you never assigned a value to i and j. And it seems even after I made i = 7 and j = 10, the compiler wouldn't create the grid. I think you would have to make i and j to be constants, but then you couldn't use them in the for loop. So, I just created grid[7][10]. Your output was NOT a grid of 7x10, but one long line. I changed the loop a bit to print 7 separate lines. Hope this helps out.
Thank you very much I finally realized what I was doing wrong :S, as I can see from your posts I realized the main Problem I had was that I never gave the grid array a true value when it was declared and therefore, for for some reason when I executed the program it crashed. Once I did that I saw that the output was only a long horizontal line, and not the grid I was intending for. After that I realized that the reason it was outputing this line was because I had put an endl command within the loop the cout command was placed and therefore created a newline not for every row, but for every character which was output into the console. So I simply moved that into the 'outer' loop which was affecting the x coordinate of the grid.
This is my final sample including the fixes I had made thanks to you guys.