473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

10 limiting display

How do you limits employee display where you enter the department for all
the employee within that department be displayed and if lets say they are
100 or so and you have to limits 10 employee per page before entering
anything to display the next 10 again?

Nov 14 '05 #1
17 2194
kimimaro <li************@yahoo.com> scribbled the following:
How do you limits employee display where you enter the department for all
the employee within that department be displayed and if lets say they are
100 or so and you have to limits 10 employee per page before entering
anything to display the next 10 again?


I tried to read that. Twice. Both times I failed to understand what
exactly you want.
Next time, try separating your sentences with punctuation marks like
these:
"," "." "!" "?" ":" ";"
For advanced users, separate paragraphs might help.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"The trouble with the French is they don't have a word for entrepreneur."
- George Bush
Nov 14 '05 #2
In article <48******************************@localhost.talkab outprogramming.com>,
kimimaro <li************@yahoo.com> wrote:
How do you limits employee display where you enter the department for all
the employee within that department be displayed and if lets say they are
100 or so and you have to limits 10 employee per page before entering
anything to display the next 10 again?


Try it this way:

Department employee 100 be per or displayed page so and before and if
the how entering you department do anything have for you to to all
limits display limits employee the 10 lets the display next say
employee where 10 they within you again are that enter?

Nov 14 '05 #3

kimimaro wrote:
How do you limits employee display where you enter the department for all the employee within that department be displayed and if lets say they are 100 or so and you have to limits 10 employee per page before entering
anything to display the next 10 again?


As far as the loop control, something using the remainder operator (%)
is typical. As far as stopping then entering, some sort of read from
stdin in used. For portable code, that means reading a line. Any other
way (Hit Any Key To Continue) requires implementation-specific features
that are off-topic here.

Here is a small code fragment that displays numbers from 1 and stopping
after every 5 to wait for a carriage return. This input is not robust,
in reality you need to handle people putting in characters before the
return, and has other safety issues for you to work out. It is only a
demonstration.

int i;

for (i = 1; ; i++)
{
printf("%d\n", i);
if (i%5 == 0)
getchar();
}


Brian

Nov 14 '05 #4
Kenny McCormack <ga*****@yin.interaccess.com> scribbled the following:
In article <48******************************@localhost.talkab outprogramming.com>,
kimimaro <li************@yahoo.com> wrote:
How do you limits employee display where you enter the department for all
the employee within that department be displayed and if lets say they are
100 or so and you have to limits 10 employee per page before entering
anything to display the next 10 again?
Try it this way: Department employee 100 be per or displayed page so and before and if
the how entering you department do anything have for you to to all
limits display limits employee the 10 lets the display next say
employee where 10 they within you again are that enter?


Right, if kimimaro next replies to this with "Thanks! That worked!"
then I'll be really scared...

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"That's no raisin - it's an ALIEN!"
- Tourist in MTV's Oddities
Nov 14 '05 #5
Really sorry for my last post I am too tired then and I only realised that
how broken my engrish(japanese english) are. Ok,
i'll try to type in a proper way now. I want to prompt the user to enter
from the selection 1 to 5 for assigning to a particular department which
I've done that. Now I want to display them by searching on the matched
department where the user want to search such as if they want to view all
employees within Accounting department they enter the correspondant
number. BUT the thing is that I wanted to limits 10 entry to be viewed
before the user hit enter again to display the next 10. If the employee
exceeds 200 it would be a problem to display them all in one go. sorry and
thanks in advance

Nov 14 '05 #6
kimimaro <li************@yahoo.com> scribbled the following:
Really sorry for my last post I am too tired then and I only realised that
how broken my engrish(japanese english) are. Ok,
i'll try to type in a proper way now. I want to prompt the user to enter
from the selection 1 to 5 for assigning to a particular department which
I've done that. Now I want to display them by searching on the matched
department where the user want to search such as if they want to view all
employees within Accounting department they enter the correspondant
number. BUT the thing is that I wanted to limits 10 entry to be viewed
before the user hit enter again to display the next 10. If the employee
exceeds 200 it would be a problem to display them all in one go. sorry and
thanks in advance


You are most probably using some sort of loop (for, while, or something)
to display the matching results. Try adding an int variable which is
initialised to 0 and incremented by 1 every time you enter the loop.
Then when this variable is divisible by 10 you call getchar(). I'd
figure it'd go something like this:

int i=0;
while (/* there are employees left in the department */) {
i++;
/* show the next employee */
if ((i%10) == 0) {
getchar();
}
}

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"The trouble with the French is they don't have a word for entrepreneur."
- George Bush
Nov 14 '05 #7

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);
while(strcmp(record[i].Department[storage],
Department[selection])==0) {
i++;
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();
}

}
This is how my display should work but I dont think it is working because
it only prints out the 1st one who matched the same department input by
the user and then the the next one below them even if it doesnt match with
the department

Nov 14 '05 #8
for (i = 1; 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();
}
}
I have 500 employees in my records and i want to compare the department in
the records and the one entered by the user to
match the search while limiting 10 per page before hit again to display
the next 10. This one almost done it but still it displayed fully. There
might be some mistakes here

Nov 14 '05 #9
hi I seems to do ok now since i've been working on it some few hours and
now the problem is after I inserted 21 person to check if it works it
display the 1st person, then 8 person, then 10 person and then 2. It
supposed to display 10, 10 then 1. This is the code:
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();
getch();
clrscr();
}

}

Thanks for helping me out

Nov 14 '05 #10
On Thu, 04 Nov 2004 12:20:28 -0500, "kimimaro"
<li************@yahoo.com> wrote:
hi I seems to do ok now since i've been working on it some few hours and
now the problem is after I inserted 21 person to check if it works it
display the 1st person, then 8 person, then 10 person and then 2. It
supposed to display 10, 10 then 1. This is the code:
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);
fflush is not defined for input streams. If you insist on posting
code that invokes undefined behavior after being told about it, you
will be taken for a troll who does just to see how many people you can
annoy.
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)
This does not cause a pause in the loop every tenth line.

It causes a pause in the loop whenever the record being printed just
happens to be a multiple of 10 from the start of the data base.

For example, if the only records that satisfy your if(strcmp... above
are records 5, 15, 25, 35, etc, then this if will never be true and
you will print everything without pause. On the other hand, if the
records that satisfy the if(strcmp are 5, 10 , 15, 20, 25, etc, you
will pause after every two records are printed.

Your division by 10 needs to be against the number of records printed,
not the number of the record in the database.
{
getchar();
getch();
What was your intent here?
clrscr();
}

}

Thanks for helping me out


<<Remove the del for email>>
Nov 14 '05 #11
> {
getchar();
getch(); What was your intent here? clrscr();
}


hi, my intent was to stop the frame before the user hit enter to clear
screen and then display another 10 employee and stop frame again while
user hit enter again to clear screen to show the next 10 employee. Im
sorry but I dont know how getchar() works and I dont know its function. I
am still having trouble of displaying please help

Nov 14 '05 #12

"kimimaro" <li************@yahoo.com> wrote in message
news:3d******************************@localhost.ta lkaboutprogramming.com...
{
getchar();
getch();

What was your intent here?

clrscr();
}


hi, my intent was to stop the frame before the user hit enter to clear
screen and then display another 10 employee and stop frame again while
user hit enter again to clear screen to show the next 10 employee. Im
sorry but I dont know how getchar() works and I dont know its function. I
am still having trouble of displaying please help

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int match(const char *s,
int c) /* pass zero to match anything */
{
return c = 0 || strchr(s, c) != 0;
}

void pause(void)
{
int c = 0;

printf("Press ENTER to continue");
fflush(stdout);

while((c = getchar()) != '\n' && c != EOF)
;
}

void output(const char *s,
FILE *fp,
size_t line_num,
size_t lines_per_page)
{
char *p = strrchr(s, '\n');

if(p)
*p = 0;

if(lines_per_page && line_num)
if(!(line_num % lines_per_page))
pause();

fprintf(fp, "%3lu: %s\n", (unsigned long)++line_num, s);
}

void select(const char *filename,
int containing,
size_t lines_per_page)
{
char line[100] = {0};
FILE *input = fopen("text.txt", "r");
size_t line_num = 0;

if(!input)
fprintf(stderr, "Cannot open input file '%s'\n", filename);
else
{
printf("%sines from file '%s'",
containing ? "L" : "All l",
filename);

if(containing)
printf(" containing character '%c'", containing);

putchar('\n');
printf("(%lu lines per page):\n", (unsigned long)lines_per_page);

while(fgets(line, sizeof line, input))
if(match(line, containing))
output(line, stdout, line_num++, lines_per_page);

if(!feof(input))
fprintf(stderr, "Error reading file '%s'\n", filename);

printf("\t*** %lu lines found ***\n", (unsigned long)line_num);
fclose(input);
line_num = 0;
}

putchar('\n');
}

int main()
{
select("text.txt", 'e', 10);
select("text.txt", 'r', 5);
select("text.txt", 'z', 20);
select("text.txt", 0, 15);
return 0;
}
-Mike
Nov 14 '05 #13

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:uZ*****************@newsread3.news.pas.earthl ink.net...

I forgot to include the input and
output from a sample run. Here it is:
INPUT (file 'text.txt'):

hi,
my
intent
was
to
stop
the
frame
before
the
user
hit
enter
to
clear
screen
and
then
display
another
10
employee
and
stop
frame
again
while
user
hit
enter
again
to
clear
screen
to
show
the
next
10
employee.
Im
sorry
but
I
dont
know
how
getchar()
works
and
I
dont
know
its
function.
I
am
still
having
trouble
of
displaying
please
help
OUTPUT:

Lines from file 'text.txt' containing character 'e'
(10 lines per page):
1: intent
2: the
3: frame
4: before
5: the
6: user
7: enter
8: clear
9: screen
10: then
Press ENTER to continue
11: another
12: employee
13: frame
14: while
15: user
16: enter
17: clear
18: screen
19: the
20: next
Press ENTER to continue
21: employee.
22: getchar()
23: trouble
24: please
25: help
*** 25 lines found ***

Lines from file 'text.txt' containing character 'r'
(5 lines per page):
1: frame
2: before
3: user
4: enter
5: clear
Press ENTER to continue
6: screen
7: another
8: frame
9: user
10: enter
Press ENTER to continue
11: clear
12: screen
13: sorry
14: getchar()
15: works
Press ENTER to continue
16: trouble
*** 16 lines found ***

Lines from file 'text.txt' containing character 'z'
(20 lines per page):
*** 0 lines found ***

All lines from file 'text.txt'
(15 lines per page):
1: hi,
2: my
3: intent
4: was
5: to
6: stop
7: the
8: frame
9: before
10: the
11: user
12: hit
13: enter
14: to
15: clear
Press ENTER to continue
16: screen
17: and
18: then
19: display
20: another
21: 10
22: employee
23: and
24: stop
25: frame
26: again
27: while
28: user
29: hit
30: enter
Press ENTER to continue
31: again
32: to
33: clear
34: screen
35: to
36: show
37: the
38: next
39: 10
40: employee.
41: Im
42: sorry
43: but
44: I
45: dont
Press ENTER to continue
46: know
47: how
48: getchar()
49: works
50: and
51: I
52: dont
53: know
54: its
55: function.
56: I
57: am
58: still
59: having
60: trouble
Press ENTER to continue
61: of
62: displaying
63: please
64: help
*** 64 lines found ***

-Mike
Nov 14 '05 #14
Hi, i appreciate your work very much but i am doing my college project and
I cannot use anything except pure C programming. I cannot use other
programming language such as c++ sorry to trouble but this is the last bit
of my program that cannot work I will not bother anymore if I can limit 10
employee per page thank you

Nov 14 '05 #15
In article <3d******************************@localhost.talkab outprogramming.com>,
kimimaro <li************@yahoo.com> wrote:
hi I seems to do ok now since i've been working on it some few hours and
now the problem is after I inserted 21 person to check if it works it
display the 1st person, then 8 person, then 10 person and then 2. It
supposed to display 10, 10 then 1. This is the code:


You're pausing when i%10==0, but i isn't counting the number of
employees you've printed; it's counting the number of employees that
you've looked at. You need to create another counter that counts how
many employees have been printed (for example, call it 'j', initialize
it to 0, increment it everytime you print a record, and then pause when
j%10==0).

-- Brett
Nov 14 '05 #16
On Sat, 06 Nov 2004 12:38:23 -0500, in comp.lang.c , "kimimaro"
<li************@yahoo.com> wrote:
Hi, i appreciate your work very much but i am doing my college project and
I cannot use anything except pure C programming. I cannot use other
programming language such as c++ sorry to trouble but this is the last bit
of my program that cannot work I will not bother anymore if I can limit 10
employee per page thank you


I expect you're using a loop to display your employees on the screen. Then
use a counter and whenever it has a value which is a multiple of ten, use
getchar() to wait for the user to press enter.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 14 '05 #17

"kimimaro" <li************@yahoo.com> wrote in message
news:11******************************@localhost.ta lkaboutprogramming.com...
Hi, i appreciate your work very much but i am doing my college project and
I cannot use anything except pure C programming.
The code I posted is pure (standard) C.
I cannot use other
programming language such as c++
There is no C++ code in my post.

sorry to trouble but this is the last bit
of my program that cannot work I will not bother anymore if I can limit 10
employee per page thank you


My example should show you everything you need.

-Mike
Nov 14 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kingdom | last post by:
I'm using this script to dynamicaly populate 2 dropdowns and dispaly the results. Choose a component type from the first drop down, lets say 'car' and the second box will list all the car...
3
by: B | last post by:
I know there are several ways to speed up combo boxes and form loading. Most of the solutions leave rowsource of the combo box blank and set the rowsource to a saved query or an SQL with a where...
2
by: Jo Davis | last post by:
access fe and access be. later the be might be sql server I don't want people to pass this application around. And I want control over usage. I want it to 'expire' after a while. I have fairly...
4
by: N J | last post by:
Hi, I ahve developed a program using access and am distributing it using MDE's, I ahve had many requests for a demo. I was thinking of limiting the number of records to say 100? If anyone has...
0
by: Waran | last post by:
Hi, Please look the fields (Insurance, Defense Attorney, Applicant/Plaintiff Attorney) under party list in http://www.reccustodian.com/defensepro/order/neworder.aspx The above said fields are...
3
by: Peter Silva | last post by:
Hi folks, I have a need in a network data distribution application to send out data to folks who want it using the protocol of their choice. IŽd like it to support a variety of protocols and I...
1
by: Technical | last post by:
Hi, I'm currently working on a webproject with ASP.NET 2.0, Visual Studio 2005, and SQL Server 2005 that allows users to search for and view images. My problems is that I need a way to limit...
1
by: eayoung | last post by:
I am using Access 2003 on a Dell XPS 400 with 512MB of video memory and side-by-side 20" monitors. It's a wonderful way to have the VB code on one side and the Access app on the other - but it has...
4
WyvsEyeView
by: WyvsEyeView | last post by:
I have a datasheet form in which one field is a combo box that will potentially contain hundreds of records. I've read about several methods of speeding up such combo boxes or limiting their initial...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.