Thread: load to an array?

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

    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
    Well, if you already know the word that you're looking for, you can just do this:
    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, 07:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10: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, 04:01 PM
  5. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM