Storing values in an array

This is a discussion on Storing values in an array within the C Programming forums, part of the General Programming Boards category; Yes, this is a homework assignment. I need to write a program that will store letters in the array named ...

  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 02:29 PM. Reason: commas instead of semicolon
    You ended that sentence with a preposition...Bastard!

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    2,917
    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, 10: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, 07: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, 09: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21