I am trying to create a basic database type program for my father so he can use it on his laptop. I know a little but not tons on C++
my code so far is just to get the basic down and get it to work.
The thing i dont know is arrays. He needs to be able to type in a shortname and the program to bring up the product with that shortname.
For example if i type in cp12c it would bring up
CATCH PLAY 1.5 CALL
how do i do this??
have tons of if statements or is it much easier? also how would i be able to compar arrays with a shortname? for example
if (shortname[array]=='123212')
{
cout<<"HI";
}
i know that doesnt work but how can i make it work???
MY BASIC CODING FOR PRACTICE IS BELOW. wat is wrong with it? it will never display hi
#include <iostream.h>
const char array=10;
int main()
{
char* shortname[array];
cout<<"Welcome!! Please type in the shortname of the product you are\nlooking for:::";
cin>>shortname[array];
if (shortname[array]=='13c3')
{
cout<<"HI!!";
}
else if (shortname[array]=='2221k')
{
cout<<"Hi again";
}
else
{
cout<<"There is no product within this database with the following shortname";
cout<<shortname[array];
}
cout<<shortname[array];
return 0;
}
my code so far is just to get the basic down and get it to work.
The thing i dont know is arrays. He needs to be able to type in a shortname and the program to bring up the product with that shortname.
For example if i type in cp12c it would bring up
CATCH PLAY 1.5 CALL
how do i do this??
have tons of if statements or is it much easier? also how would i be able to compar arrays with a shortname? for example
if (shortname[array]=='123212')
{
cout<<"HI";
}
i know that doesnt work but how can i make it work???
MY BASIC CODING FOR PRACTICE IS BELOW. wat is wrong with it? it will never display hi
#include <iostream.h>
const char array=10;
int main()
{
char* shortname[array];
cout<<"Welcome!! Please type in the shortname of the product you are\nlooking for:::";
cin>>shortname[array];
if (shortname[array]=='13c3')
{
cout<<"HI!!";
}
else if (shortname[array]=='2221k')
{
cout<<"Hi again";
}
else
{
cout<<"There is no product within this database with the following shortname";
cout<<shortname[array];
}
cout<<shortname[array];
return 0;
}