Thread: creating staff system

  1. #16
    Registered User
    Join Date
    Jul 2017
    Posts
    48
    thk u guys for helping me...i now have solve the problem....i really appreciate it

  2. #17
    Registered User
    Join Date
    Jul 2017
    Posts
    48
    Code:
    void searchStaff() {
    
    
    	int id, found;
    	struct staff sta;
    	FILE*fp2, *temp;
    
    
    	printf("Enter the ID number you want to search:\n ");
    	scanf("%d", &id);
    
    
    	fp2 = fopen("Record", "rb");
    	temp = fopen("temp", "wb");
    	printf("Staff Details\n");
    	printf("ID NUMBERS\t NAME\n");
    	printf("=========================");
    	while (fread(&sta, sizeof(sta), 1, fp2) != 0)
    	{
    		if (id == sta.id) {
    			printf("%d\t\t %s\n", sta.id, sta.name);
    			found = 1;
    
    
    		}
    		else {
    			printf("No such record!!");
    			fwrite(&sta, sizeof(sta), 1, temp);
    			found = 0;
    
    
    		}
    	}
    	fclose(fp2);
    	fclose(temp);
    	if (found == 1) {
    		system("Record");
    	}
    }
    also trigger break point during while (fread(&sta, sizeof(sta), 1, fp2) != 0)

  3. #18
    Registered User
    Join Date
    Jul 2017
    Posts
    48
    no..i'm using %s

  4. #19
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    1. You're not checking that both fopen() calls succeeded (or not).
    Especially when you keep changing the filename to "Report" or "Record" or ....

    2. What does this do?
    system("Record");
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WSF-Staff
    By Elkvis in forum Tech Board
    Replies: 0
    Last Post: 06-19-2014, 09:17 AM
  2. technical staff
    By Kenan1975 in forum Windows Programming
    Replies: 1
    Last Post: 08-01-2010, 06:13 AM
  3. Creating a menu system
    By ICool in forum C Programming
    Replies: 9
    Last Post: 09-17-2007, 12:18 PM
  4. Looking for staff
    By Daniel Primed in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 01-19-2006, 07:17 PM
  5. Looking for an immortal staff and a builder or two
    By ~Kyo~ in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 05-01-2005, 12:05 PM

Tags for this Thread