Thread: Storing values in an array

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    10

    Storing values in an array

    Yes, this is a homework assignment.

    I need to write a program that will store letters in the array named "message": This is a test.

    The program is to copy the data stored in "message" to another array named mess2 and then display the letters in the mess2array.

    I'm not working out of a book, and I DO NOT expect someone to do this assignment for me, I'm just looking for a clearer explanation. Thanks!

  2. #2
    The Dragon Reborn
    Join Date
    Nov 2009
    Location
    Dublin, Ireland
    Posts
    629
    i love c++ for this..but with c
    ah well, since you know the amount of the string i guess you allocate static memory for mess2
    and you use a for loop, if you're doing strings I assume you've done iteration and conditional flow.
    and with each iteration you had
    assign a character to mess2, remember to leave an index for the null character.
    Code:
          for(int i;i < N; i++)
                m2[] = m1[];
    Last edited by Eman; 04-12-2011 at 01:29 PM. Reason: commas instead of semicolon
    You ended that sentence with a preposition...Bastard!

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    I'm not working out of a book
    Why not? Using a book when first learning gives you examples and explanations.

    Take a look at this link for Arrays and Character sequences.
    They should help explain the basic issues.

    Jim

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    This will do it very easily...

    C standard library:string.h:strcpy - clc-wiki

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Storing values into a dynamic array
    By porsche911nfs in forum C++ Programming
    Replies: 5
    Last Post: 04-24-2009, 09:08 AM
  2. Storing values from Edit Box into an array
    By E_I_S in forum C++ Programming
    Replies: 10
    Last Post: 06-05-2008, 06:24 AM
  3. Storing values from an array pointer
    By newatc in forum C Programming
    Replies: 21
    Last Post: 01-07-2008, 06:46 AM
  4. int array isn't storing proper values.
    By System_159 in forum C++ Programming
    Replies: 1
    Last Post: 08-31-2006, 08:55 AM
  5. quick question about storing values in an array
    By houler in forum C Programming
    Replies: 7
    Last Post: 12-10-2004, 01:33 PM