Thread: arrays

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    18

    arrays

    using
    Code:
    int ExecuteCommand(int com[], int max)
    {
    int Tfloor[FLOORSIZE][FLOORSIZE];
    
    int i, move, penup, pendown, n, s, e=1, w;
    for(i=0;i< max;i++)
    {
    switch (com[i]) {
     case 1:
          cout << "penup\n";
          penup=1;
     break;
    
     case 2:
          cout << "pendown\n";
          pendown =1;
     break;
    
     case 3:
          cout << "right\n";
    w=1;
     break;
    
     case 4:
          cout << "left\n";
     e=1;
    break;
    
     case 5:
    // case 5 .. uses
    //com[i + 1] to get the value of how many spaces to move..
    // assuming i know wat direction i wanna go..
    // i put an if statement.. and then how do i fill an array.. 
    // i have to convert pendown to 1s and pen up to 0..
    // do i make sense....
     Tfloor[FLOORSIZE][FLOORSIZE]=; // how do i fill an array..
          DisplayFloor(Tfloor, FLOORSIZE)
     break;
    }
    
    }
    }
    how do i convert the above to something like this and put it into
    int Tfloor[FLOORSIZE][FLOORSIZE] = {1, 1, 1, 1, 1,
    0, 0, 0, 0, 0};
    until the end of the loop..


    ta..


    Code tags added by Kermi3
    Last edited by chizzy; 09-14-2002 at 10:20 PM.

  2. #2
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    Please use code tags

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    18
    wat do u mean

  4. #4
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    Well, basically you put [ CODE] above your code, without ther space, and [ /CODE] below it, without space. It is the equivalent of <pre> tags, and it lets yout code's indentation carry over onto the board.

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function to read in two arrays
    By ssmokincamaro in forum C Programming
    Replies: 7
    Last Post: 11-12-2008, 07:59 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM