Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,084 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,543 people online right now. Registration is fast and FREE... Join Now!




How can I make it print correctly?

 
Closed TopicStart new topic

How can I make it print correctly?

camaroer87
12 Apr, 2008 - 11:23 AM
Post #1

New D.I.C Head
*

Joined: 13 Mar, 2008
Posts: 40

Here's my print code:
CODE

void printBoard(char gameBoard[][COLUMNS], char gameBoard2[][COLUMNS])
{
    int i;
    int j;
    
    printf("A B C D E F G H I J            A B C D E F G H I J\n\n");
    
    for(i = 0; i < ROWS; i++)
    {
        for(j = 0; j < COLUMNS; j++){
            printf("%c ", gameBoard[i][j]);
        }
        printf(" %d",i+1);    
    
        printf("\n");
    }    
    
    
    for(i = 0; i < ROWS; i++)
    {
        printf("                    ");
        for(j = 0; j < COLUMNS; j++)
            printf("%c ", gameBoard2[i][j]);
    
        printf(" %d",i+1);    
    
        printf("\n");
    }    

    
    printf("\n");        
}


there is a pic of the output attached

I want to move the array printout in the bottom right up so that
it is lined up with the top array. Only a verictal move.

Thanks


Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: How Can I Make It Print Correctly?
12 Apr, 2008 - 12:53 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,435



Thanked: 64 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
printf cannot just throw text to a direct alignment. You would need to use functions that can write to specific areas of the screen (conio.h in Windows), or write both arrays out as you are on the correct line.
User is online!Profile CardPM
+Quote Post

camaroer87
RE: How Can I Make It Print Correctly?
12 Apr, 2008 - 08:01 PM
Post #3

New D.I.C Head
*

Joined: 13 Mar, 2008
Posts: 40

So the way I want to do it wont work, what then? Do somehow make 1 array and have a space or what? I cant figure out how to print on the correct line. I have moved that second array's print statement all over the place.

This post has been edited by camaroer87: 12 Apr, 2008 - 08:03 PM
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: How Can I Make It Print Correctly?
12 Apr, 2008 - 09:14 PM
Post #4

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,858



Thanked: 49 times
Dream Kudos: 550
My Contributions
There are lots of ways to do this -- none of them really all that fun.

Basically there are two approaches:

Print both boards data in the same Printf statements.

Create a buffer and write your own print statments to write to the buffer. Then when you have finished your calculation print the entire buffer.
User is offlineProfile CardPM
+Quote Post

camaroer87
RE: How Can I Make It Print Correctly?
13 Apr, 2008 - 07:44 AM
Post #5

New D.I.C Head
*

Joined: 13 Mar, 2008
Posts: 40

Well I don't know anything about buffers, so I'll work with the same printf idea. I did try this but the output is very messed up, no matter where I tell the placeholder to go. Do the loops have to be changed as well?
User is offlineProfile CardPM
+Quote Post

camaroer87
RE: How Can I Make It Print Correctly?
13 Apr, 2008 - 03:05 PM
Post #6

New D.I.C Head
*

Joined: 13 Mar, 2008
Posts: 40

K I got it, just had to delete some lines of code from what I had.
User is offlineProfile CardPM
+Quote Post

Closed TopicStart new topic
Time is now: 12/1/08 08:01PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month