Thread: Searching structure piece

  1. #1
    Registered User
    Join Date
    Sep 2003

    Searching structure piece

    I have an structure array containg information about students of a class. The Information was read from a file into the structures. I then display this information and ask the user to pick a student by entering their ID number, i then send the ID and the structure of students to a function and search the structure for that student and specifically display their information only. I have this .. a function that supposed to search and compare students ID with the user entered ID, and print out that students information.

    void find_applicant(struct school *student, char ID[10], int NumEmp)
    	int i;
    	for(i=0; i<NumEmp; i++)
    		if(strcmp(ID, student[i].appnum) = 0)
    			printf("%s\n", student[i].appnum);
    			printf("%s\n", student[i].fname);
    			printf("%s\n", student[i].lname);
    			printf("%10.0lf\n", studen[i].pnum);
    			printf("%s\n", student[i].email);
    			printf("%d\n", student[i].numskl);
    			printf("%d\n", student[i].year);
    			printf("%s\n", student[i].make);
    			printf("%s\n\n\n", student[i].mod);
    it keeps telling me "invalid lvalue assignment" for the line with strcmp. I don't understand the problem. Thanks for any help or advice given.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    if(strcmp(ID, student[i].appnum) = 0)
    This is an (attempted) assignment.
    if(strcmp(ID, student[i].appnum) == 0)
    This is a comparison.

    printf("%10.0lf\n", studen[i].pnum);
    This is undefined behavior.
    Last edited by Dave_Sinkula; 10-20-2003 at 08:51 PM.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need a second opinion - code error and i cant see it
    By bigfootneedhelp in forum C Programming
    Replies: 19
    Last Post: 10-25-2007, 06:02 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Visual C++ 2005 linking and file sizes
    By Rune Hunter in forum C++ Programming
    Replies: 2
    Last Post: 11-12-2005, 10:41 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM