Thread: question on strings...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    21

    Question question on strings...

    Ok, I'm doing this assignment, and I have to have a string variable with 5 names in it. Ok, so naturally I think of a 5 dimention array, like this:

    names[5][20]

    Or something. Ok so he says we can only use one array variable, but I'm having trouble. I read that you can't re-assign values to a string once it was defined, but that you can initialize it right away. So can anyone tell me how to get these names into a single string variable upon definition?

    Larry Lister
    Sue Sales
    Eva Escrow
    Morley Money
    Pete Profit

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231

    Re: question on strings...

    >>names[5][20]
    Looks good.

    >>so he says we can only use one array variable,
    That is only one array variable.

    >>I read that you can't re-assign values to a string once it was defined, but that you can initialize it right away.
    I think you're talking about string literals. You can put new data into arrays like the one declared here.

    >>can anyone tell me how to get these names into a single string variable upon definition?
    Do you mean:
    char Names[][20] = {"Name1", "Name2" .... etc
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    21
    You know, a part of me knew that, I just didn't realize it. Thanks for your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about strings in c
    By gp364481 in forum C Programming
    Replies: 9
    Last Post: 11-13-2008, 06:32 PM
  2. Question About Strings
    By spanker in forum C++ Programming
    Replies: 1
    Last Post: 07-13-2008, 05:09 AM
  3. strings question
    By cstudent in forum C Programming
    Replies: 4
    Last Post: 04-18-2008, 07:28 AM
  4. Functions and Strings Question
    By StrikeMech in forum C Programming
    Replies: 4
    Last Post: 07-18-2007, 06:07 AM
  5. Strings question
    By kimimaro in forum C Programming
    Replies: 10
    Last Post: 03-15-2005, 12:14 AM