Thread: comparing and printing

  1. #1
    Unregistered
    Guest

    comparing and printing

    i have implemented an array of structures, and stored student data such as, name, age, sex, course, location, and p/t or f/t.

    i now wish the user to enter a course, and for it to display all students on that course, but, only if they are f/t.

    how do i take the user input and compare it to the information i have stored in the array? and only display the students that are f/t?

    something along the lines of...

    printf("Enter course");
    scanf("%s", SelectedCourse);

    int course(struct student class[])
    for (i=0; i < CLASS_SIZE; ++i)
    class[i].course == '&SelectedCourse';

    ?? and how do i also do i get it to check whether the student is f/t or p/t?

    cheers for any help.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Assuming p/t and f/t are integers with a true/false value:
    Code:
    for ( i = 0; i < SIZE; i++ ) {
      if ( class[i].ft == TRUE && 
           strcmp ( class[i].course, selection ) == 0 )
      {
        /* Print the student data */
      }
    }
    -Prelude
    My best code is written with the delete key.

  3. #3
    Unregistered
    Guest
    cheers for that, but, where you have written /* Print the student data */ i want the student data from the structure of arrays to be printed. i want it to get take the related data and print it out. and the relevant data to be determind by the user input. any ideas?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Comparing numbers to a list of numbers held in a text file
    By jmajeremy in forum C++ Programming
    Replies: 3
    Last Post: 11-06-2006, 07:56 AM
  2. Replies: 2
    Last Post: 12-12-2005, 10:07 AM
  3. comparing arrays
    By dustyrain84 in forum C Programming
    Replies: 1
    Last Post: 01-21-2004, 05:52 PM
  4. comparing character arrays
    By Neildadon in forum C++ Programming
    Replies: 2
    Last Post: 04-18-2003, 05:29 AM