Thread: Dynamic Two-Dimensional Arrays

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Show us the code for loading the dimensions from the file; and then post the file itself.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    C++ n00bie :D
    Join Date
    Jul 2004
    Posts
    63
    Its pretty darn absic... I updated the loading of dimensions with get(), and used atoi to make it int. works much better and now only problem is it doesnt load what I want it too(the values come out 0x0, instead of 10x10, doesnt close instant now though)

    Set-Size function:
    Code:
    void testclass::setsize() {
      char *char_length=new char[3];
      char *char_width=new char[3];
      std::ifstream s_size(dat_filename);
      s_size.get(char_length, 2, ' ');
      s_size.get(char_width, 2, ' ');
      s_size.close();
      dat_length=atoi(char_length);
      dat_width=atoi(char_width);
    }//testclass setsize func
    The file:
    Code:
    10 10
    00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00
    The file is pretty basic, just a test right now. Its just that it doesnt load the first two properly.
    Last edited by LloydUzari; 08-09-2004 at 04:07 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating and freeing dynamic arrays
    By circuitbreaker in forum C++ Programming
    Replies: 8
    Last Post: 02-18-2008, 11:18 AM
  2. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  3. Dynamic two dimensional arrays
    By ThWolf in forum C++ Programming
    Replies: 14
    Last Post: 08-30-2006, 02:28 PM
  4. processing dynamic arrays
    By Mario F. in forum C++ Programming
    Replies: 9
    Last Post: 06-04-2006, 11:32 AM
  5. Dynamic (Numeric) Arrays
    By DavidB in forum C++ Programming
    Replies: 5
    Last Post: 05-03-2006, 07:34 PM