Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string manipulation???

Status
Not open for further replies.

mharvin

Instructor
Apr 6, 2001
3
PK
Hello tek-experts!
I have a problem, can anybody help me with this?

Make a database program that will keep track of some products such as cucumber, potatoes, mango etc. There will be a menu wherein you can list the products, read, write and then quit from the program. If you select (l)ist, it will list 9 products with their quantity; if you select
(w)rite then you can edit the name of a certain product and save it; if you select (r)ead then you can view the edited product name.

My idea is about string manipulation. Is this right?

Thanks.

mharvin :)
 
because the option you want to provided to be selected in the program is only a character at a time ('l', 'w', and 'r'). so you don't need to have string manipulation for it. just use char data type.

Code:
/* example code. */
int getOption()
{
   unsigned char option;
   if (((option = getch()) == 0) || (option == 224))   /* extended or function key? */
      getch();   /* clear I/O buffer. */
   return option;
}

void processOption(int option)
{
switch (option) {
case 'l':
/* execute list statements. */
break;
case 'w':
/* execute write statements. */
break;
case 'r':
/* execute read statements. */
break;
default:
/* handle error option chosen. */
}
}
 
how about with the database? how can i do that?
thanks... mharvin
 
What database are you using? Most databases includes some kind of API that you can use. //Daniel
 
can anyone send me the code to emulate a scanf function,(i.e)the function should do all the work of scanf and there should be no scanf in the program.
 
coolzig : Your question does not seem to belong here ....

BUT :

The source-code for scanf is included with Microsoft Visual C++ v6.0 :
C:\Program Files\Microsoft Visual Studio\VC98\CRT\SRC\CSCANF.C

and

input.c ... and probably some more files.

/JOlesen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top