2d arrays

This is a discussion on 2d arrays within the C++ Programming forums, part of the General Programming Boards category; I totally forgot how to do 2d arrays i knew on another type of c++ borland language you would do ...

  1. #1
    Registered User snowy101's Avatar
    Join Date
    May 2002
    Posts
    22

    Exclamation 2d arrays

    I totally forgot how to do 2d arrays i knew on another type of c++ borland language you would do string[10][10] for a 2d array but with borland c++ vrs 6 i have no idea what to do plz help and if possible give me a template to see how it works any info would be greatly apprshated.
    Simple Programming

    :::: Error Message != A Smile ::::

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    it should be as follows

    char string[10][10];
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Unregistered
    Guest

    this is snowy101

    this is snowy i tried that and for some reason it gives me an error message i tried a few things like that actually its making me frusterated because i just need to change something from a 1d array to a 2d array any other suggestions or ideas?

  4. #4
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563

    Post

    You must write something before that.

    this is an example for a 2d-array initialized with all codes needed.

    PHP Code:
    #include <iostream>

    void main()
    {
      
    int i,j;
      
    int arr[10][10];
      for(
    i=0i<10i++)
      {
        for(
    j=0j<10j++)
        {
          
    arr[i][j]=0;
          
    cout << arr[i][j];
        }
        
    cout << endl;
      }

    Good luck.
    Last edited by black; 07-05-2002 at 03:53 AM.
    Never end on learning~

  5. #5
    Registered User snowy101's Avatar
    Join Date
    May 2002
    Posts
    22

    well the int worked

    thanks alot the int worked thanks black really appreshiate it
    Simple Programming

    :::: Error Message != A Smile ::::

  6. #6
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107
    Maybe the name 'string' caused a conflict with string class?

  7. #7
    Unregistered
    Guest
    this is snowy101 if there was a problem with the string class how would i go about fixing it if you need my code jsut send me a message and ill e-mail you it.

  8. #8
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563
    Originally posted by Unregistered
    this is snowy101 if there was a problem with the string class how would i go about fixing it if you need my code jsut send me a message and ill e-mail you it.
    Your could compare your codes with the lines below, it works fine.
    hope it helps~
    PHP Code:
    #include <iostream>
    #include <string>

    void main()
    {
      
    int ij;
      
    string arr[10][10];
      for(
    i=0i<10i++)
      {
        for(
    j=0j<10j++)
        {
          
    arr[i][j]="element ";
          
    cout << arr[i][j];
        }
      
    cout << endl;
      }
      
    cin >> "what";

    Last edited by black; 07-07-2002 at 09:19 PM.
    Never end on learning~

  9. #9
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >it works fine
    .
    .
    >void main()
    What's wrong with this picture?

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with 2d arrays
    By thamiz in forum C Programming
    Replies: 25
    Last Post: 05-25-2008, 06:06 AM
  2. 2D Array's, assigning chars.
    By gman89 in forum C Programming
    Replies: 9
    Last Post: 04-27-2008, 12:03 AM
  3. Initialising 2D and 3D arrays
    By fry in forum C++ Programming
    Replies: 5
    Last Post: 08-01-2002, 05:34 AM
  4. Reading 2d arrays from file?
    By Ringhawk in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2002, 09:05 PM
  5. how can i pass 2d arrays
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 11-02-2001, 07:33 AM

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