load to an array?

This is a discussion on load to an array? within the C++ Programming forums, part of the General Programming Boards category; Alot of experimentation... this is awesome and key to learning code definately; it's just that even through extreme research via ...

  1. #1
    random number generator reRanger's Avatar
    Join Date
    Oct 2004
    Posts
    44

    load to an array?

    Alot of experimentation... this is awesome and key to learning code definately; it's just that even through extreme research via the Net I am having trouble finding and understanding (mostly understanding) one little element: how does one take standard user input(string) parse it in search of one word, then place this wordin in an array (a holding place where it can stand and be used in forward function) I hate to ask for help, but sometimes thats the only way to learn.
    Thanks, reRanger
    "Nay! But you love the present life!"

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Well, if you already know the word that you're looking for, you can just do this:
    Code:
    char word[] = "hello";
    No input or searching required.

    OK, seriously, if you're using C style functions you use strstr() to find the word and strncpy() to copy a certain number of characters from one array to the other.

    If you're using the C++ string class you use the find() member function to find the word you are looking for and the substr() member function to extract it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 08:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 11:33 AM
  3. Replies: 6
    Last Post: 11-09-2006, 03:28 AM
  4. Just finished assembly assignment
    By xddxogm3 in forum Tech Board
    Replies: 6
    Last Post: 10-08-2005, 05:01 PM
  5. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 05:15 AM

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