Thread: 2d array of strings?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    117

    2d array of strings?

    Hi,
    I have an assignment in which one of the requirements is to read a file which has a person's name as well as their classes they have taken.

    such as

    Jerry,CSE1320,CSE1310
    Bob,CSE1325,CSE1320,CSE1310
    Larry,CSE1105
    George,CSE1310,CSE1105

    So basically the number of classes is not a set amount. (though it will be less than 10).

    I planned on making a 2d array of strings for this so that the first column would be nothing but names. Then the following columns would be the classes taken for that name. When writing the code however I fell into a hard-spot where I realized that creating this 2d array (dynamically allocating memory) was really just creating a 2d array of characters.

    Question is in order to make what I described before would I actually have to make a 3d array of characters? If so is there an easier way to go about this? Just wondering on opinions, because I'm sure if a 3d array solves this there must be an easier way.
    Last edited by mgracecar; 04-25-2012 at 07:49 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing an array of strings until array == NULL
    By mikemhz in forum C Programming
    Replies: 10
    Last Post: 11-04-2011, 01:09 PM
  2. Swapping strings in an array of strings
    By dannyzimbabwe in forum C Programming
    Replies: 3
    Last Post: 03-03-2009, 12:28 PM
  3. Replies: 2
    Last Post: 04-27-2008, 03:39 AM
  4. malloc() strings VS array strings
    By Kleid-0 in forum C Programming
    Replies: 5
    Last Post: 01-10-2005, 10:26 PM
  5. 2d array of strings
    By localrob in forum C Programming
    Replies: 6
    Last Post: 08-23-2004, 02:49 PM