limitations of 10 employees per page

Reply

Join Date: Oct 2004
Posts: 11
Reputation: kimimaro is an unknown quantity at this point 
Solved Threads: 0
kimimaro kimimaro is offline Offline
Newbie Poster

limitations of 10 employees per page

 
0
  #1
Nov 5th, 2004
Yo guys, I am doing a function to display selections of department for the user to input and if the department is chosen, it will then match the department with the department in the database allowing only employees within that department to be displayed, but the employees can be as much as 500 person and I want them to be displayed 10 person at a go before the user hit keypad to display the next 10 meaning to say if I have 500 employees within that department it should
display 10, 10, 10 up to the 500th employee within that department
the problem is after I inserted 21 person to check if it works it
display it display 9 person then hit it display 10 without clearscreen then 2. I wanted it to display 10 then clearscreen before it display the next 10 again.

Here are the codes :


do	{
	printf("\n\n 0) %s\n 1) %s\n 2) %s\n 3) %s\n 4) %s\n \n [Enter the Department to search for employee]: ", Department[0], Department[1], Department[2], Department[3], Department[4]);
   fflush(stdin);
	scanf("%d",&selection);
  	if((selection !=0) && (selection !=1) && (selection !=2) && (selection !=3) && (selection !=4)) {gotoxy(1, 24); printf(" >>invalid Department<< Retry!\a");}
  	} while(selection < 0 || selection > 4);

     clrscr();




            
            printf("\n\n%s%s----------\n", lines, lines);
            printf("ID\tFirst Name\t\tDepartment\t\tPost\n%s%s----------\n", lines, lines);
            for (i=0;i<500;i++)
				{
            if(strcmp(record[i].Department[storage], Department[selection])==0)
            {
            printf("\n\n%s\t%s %s\t\t%s\t\t%s", record[i].ID, record[i].Name, record[i].Name2, record[i].Department[storage], record[i].Post[rank]);
            
            }

               if(i%10==0)
            {
             getchar();

            }
             
             
   			} 
really need some help I try to include clrscr(); after the getchar() but it doesn't works thanks in advance
Last edited by alc6379; Nov 7th, 2004 at 5:37 pm. Reason: added [code] tags
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: limitations of 10 employees per page

 
1
  #2
Nov 5th, 2004
Try use "system(cls);" instead of "clrscr()". I assume you are using a newer compiler...
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 11
Reputation: kimimaro is an unknown quantity at this point 
Solved Threads: 0
kimimaro kimimaro is offline Offline
Newbie Poster

Re: limitations of 10 employees per page

 
0
  #3
Nov 5th, 2004
sorry this is a college project so we cant use anymore than just C . I still cant display 10 per 10 properly
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: limitations of 10 employees per page

 
0
  #4
Nov 5th, 2004
Originally Posted by kimimaro
sorry this is a college project so we cant use anymore than just C . I still cant display 10 per 10 properly
"system" function is available in C, in stdlib.h. So, I guess you can use it without any restrictions.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 11
Reputation: kimimaro is an unknown quantity at this point 
Solved Threads: 0
kimimaro kimimaro is offline Offline
Newbie Poster

Re: limitations of 10 employees per page

 
0
  #5
Nov 5th, 2004
Oh i see thanks for the info but may i know how it works? Thanks
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: limitations of 10 employees per page

 
0
  #6
Nov 5th, 2004
Just include <stdlib.h> into your .c file, then, instead "clrscr()", write "system(cls)". This is a call to a system function, that clears the screen.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 11
Reputation: kimimaro is an unknown quantity at this point 
Solved Threads: 0
kimimaro kimimaro is offline Offline
Newbie Poster

Re: limitations of 10 employees per page

 
0
  #7
Nov 6th, 2004
Originally Posted by frrossk
Just include <stdlib.h> into your .c file, then, instead "clrscr()", write "system(cls)". This is a call to a system function, that clears the screen.
im using borland 5.02 cant use the system(cls) it cant even compile that's funny... Hmmm...
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,630
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 718
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: limitations of 10 employees per page

 
0
  #8
Nov 6th, 2004
>that's funny...
What's funny is that frrossk made the exact same mistake twice, thus ensuring that the solution wouldn't work. The argument to the system function is a string designating a system shell command, so the correct call would be:
  1. system ( "cls" );
However this is not recommended. While system is a standard function, the argument you pass it can never be completely portable. Most notably is that on DOS and Windows machines, cls will work, but only POSIX machines, clear is the command you need. On top of that, system calls the first program it encounters with a matching name and argument list as specified by the string. So if cls is a malicious program, bad things will happen. If cls is a benign program that does something other than clear the console window, you'll have a strange bug. Finally, system is a slow function. Clearing the screen is usually a common operation in programs that use it, so you want the solution to be as fast as possible. Invoking a system command interpreter is rarely a good idea when there are alternatives.

If you don't care about all of this then I still recommend adding a level of abstraction to make life easier for you down the road:
  1. #include <stdlib.h>
  2.  
  3. void clear_screen ( void )
  4. {
  5. system ( "cls" );
  6. }
Then scatter calls to clear_screen across your program. When you find the need to move to a different platform, changes only need to be made to the body of clear_screen rather than however many times you would have called system. Isolating the nonportable aspects of your program from everything else is a good habit to get into even if you only use them once or twice.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: limitations of 10 employees per page

 
0
  #9
Nov 8th, 2004
Originally Posted by Narue
>that's funny...
What's funny is that frrossk made the exact same mistake twice, thus ensuring that the solution wouldn't work. The argument to the system function is a string designating a system shell command, so the correct call would be:
  1. system ( "cls" );
However this is not recommended. While system is a standard function, the argument you pass it can never be completely portable. Most notably is that on DOS and Windows machines, cls will work, but only POSIX machines, clear is the command you need. On top of that, system calls the first program it encounters with a matching name and argument list as specified by the string. So if cls is a malicious program, bad things will happen. If cls is a benign program that does something other than clear the console window, you'll have a strange bug. Finally, system is a slow function. Clearing the screen is usually a common operation in programs that use it, so you want the solution to be as fast as possible. Invoking a system command interpreter is rarely a good idea when there are alternatives.

If you don't care about all of this then I still recommend adding a level of abstraction to make life easier for you down the road:
  1. #include <stdlib.h>
  2.  
  3. void clear_screen ( void )
  4. {
  5. system ( "cls" );
  6. }
Then scatter calls to clear_screen across your program. When you find the need to move to a different platform, changes only need to be made to the body of clear_screen rather than however many times you would have called system. Isolating the nonportable aspects of your program from everything else is a good habit to get into even if you only use them once or twice.
Thx for correction, Narue...It looks like sometimes my brain takes a break...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC