C/HELP
Expert: Joydeep Bhattacharya - 2/13/2007
QuestionHi... i just want to ask somehelp from experts like you...
this is the question...
We were asked to create a program that will allow the entry of a maximum of 50 names.Then the user will enter the name one by one, in the following format:
lastname,firstname,middleinitial.The program should allow exit from entry of names before reaching the maximum unit by using an entry of "X" on the last name.Then display the list of names using the same format.Display of names must not exceed 10 person at a time. Allow the pressing of spacebar key to display other names and escape key to exit program without finishing through the names.
Thats all... thanks... please response...
AnswerHi Carl
I have been planning to solve this problem for a long time .. thanx for giving the splendid opportunity to solve this problem.
Here I have prepared something for you with a test string of 10 strings and displaying 4 at a time ... Please go through the script and lemme know you liked the logic or not.
/* Source Code */
#include<stdio.h>
#include<conio.h>
void main()
{
char str[10][10], ch;
int i;
clrscr();
//for input string
for(i=0;i<10;i++)
{
printf("Enter %d string: ",i+1);
gets(str[i]);
}
//for display string
for(i=0;i<10;i++)
{
printf("\n\t");
printf("%s",str[i]);
if(i%3==0 && i>=3)
{
printf("\n\n\t\tPress any key to continue, ESC to quit");
ch = getch();
if(ch==27)
{
printf("\n\n\t\tAll files has not been displayed !");
break;
}
else
continue;
}
}
getch();
}
Try this code for as many strings as you like ...
Please feel free to contact me in case of any doubts or problems
Regards
Joydeep Bhattacharya