Could someone possibly take a look at this?

This is a discussion on Could someone possibly take a look at this? within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream> using namespace std; // Prototype for function displayinfo void displayInfo(int info [3] [3]); int main() { int ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    11

    Could someone possibly take a look at this?

    Code:
    #include <iostream>
    
    using namespace std;
    
    // Prototype for function displayinfo
    void displayInfo(int info [3] [3]);
    
    int main()
    {
    	int info[3][3];
    
    	
    
    
    	displayInfo(info);
    
    	return 0;
    }
    
    // Function displayinfo
    void displayInfo(int info [3] [3])
    {
    
    	for (int row = 0; row < 3; row++)
    
        cout << "Row " << row+1 << ": " << endl; 
    
        for (int col = 0; col < 3; col++) 
    {
           cout << info[row][col] << " ";
    }
    	cout << "*** ";
    
    }

    can someone tell me why the display of my cout statements are lining up with my rows?

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Check your C++ book on the format for a for-loop. If you used proper indenting in your code, you would spot a problem like that immediately.

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    11
    jeese dont gotta be so mean about it

  4. #4
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    Quote Originally Posted by Joe123
    jeese dont gotta be so mean about it
    he wasn't being mean. formatting your code correctly is a good habit to get into and helps you to avoid errors like this.
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    How's this:

    Check your C++ book on the format for a for-loop. If you used proper indenting in your code, you would spot a problem like that immediately.


  6. #6
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    roflmao!!!!
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 12-01-2007, 01:06 AM
  2. What the heck am I possibly doing wrong?
    By QuestionC in forum Tech Board
    Replies: 2
    Last Post: 04-29-2007, 08:43 PM
  3. A-Team to possibly become a movie
    By hk_mp5kpdw in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-12-2004, 09:07 PM
  4. advice and possibly guidance
    By nazri81 in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2002, 09:19 PM
  5. What could have possibly caused this garbage?
    By kreyes in forum C Programming
    Replies: 4
    Last Post: 03-07-2002, 07:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21