Thread: Getting Indexes

  1. #1
    C++ Beginner !!!
    Join Date
    Jul 2010
    Posts
    96

    Getting Indexes

    Hello!

    I have 2 columns with strings. I have to make a matrix for the strings entries.
    I wished to know how can i store the indexes of the string?

    Eg:
    #index# coulumn 1 # column 2 # value

    1 ABC XYZ 2
    2 abc xyz 3
    3 PQR EFG 1
    4 pqr efg 2


    the matrix shd look like

    1 2 3 4
    1
    2
    3
    4

    can u please help with some pseudocode...I have no clue here!

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I don't understand why you want to store the string's indeces - that's a built in feature of the matrix itself. In C, they begin at 0, btw.

    A 2D matrix should be OK for storing rows of strings:
    Code:
    char matrix[20][36]= {
    {"Apple 1"},
    {"Baywood 4"},
    {"Cherry 3"},
    {"Cedar 2"}
    };
    would give you 20 rows of storage, with each row having 35 columns for char's, at most. One element of the matrix would need to store the end-of-string marker: '\0'.

    You haven't given nearly enough information for pseudocode for a program, to be created. This is something you really need to work on - if you have no clue, talk to another classmate or your teacher and get some.

    Even the great Sherlock Holmes had to get some clues, after all.

  3. #3
    C++ Beginner !!!
    Join Date
    Jul 2010
    Posts
    96
    hello!
    Thanks...but i know how to create and store 2 D matrix but I have 2000 or more entries.
    Its not easy to make matrix according to the names of the columns do I wanted to make it by indexes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-09-2010, 03:31 PM
  2. Indexes of arrays in C starting with 1
    By RafaelMarch in forum C Programming
    Replies: 12
    Last Post: 10-30-2009, 01:44 PM
  3. MySQL Indexes
    By LuckY in forum Tech Board
    Replies: 1
    Last Post: 05-09-2007, 06:04 PM
  4. 2D arrays with variable indexes
    By homeyg in forum C++ Programming
    Replies: 13
    Last Post: 01-22-2005, 10:40 PM
  5. Sort indexes of frequency array?
    By davidol in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 09:04 AM