Thread: strings/input-output

  1. #1
    Registered User
    Join Date
    Apr 2010


    I've been given an assignment which asks me to write a program that does the following:
    -Opens a file which contains 50 last names and student IDs
    -Gives the user the option of searching by last name or ID
    -If there is a match, both the name and ID will be printed.
    -If there is no match, an error statement is printed.

    I know how to get the program to open a file, but I'm not sure what to use for searching the file for a name. Any suggestions?

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Do you know the exact format of the file, for example:
    name id
    name id

  3. #3
    Registered User
    Join Date
    Apr 2010
    yes, its like

    Johnson 123-45-6789

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    So read in the data into a data structure of your choosing (if it's always 50, then that suggests an array; if it's not always 50, then you'll probably want something dynamic); then as your user requests searches, you can search through the data structure to find the results.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code output...
    By roaan in forum C Programming
    Replies: 6
    Last Post: 07-03-2009, 02:22 AM
  2. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 02:08 PM
  3. Replies: 4
    Last Post: 11-30-2005, 03:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 04:27 AM
Website Security Test