begum wrote:
> in my program ý want to use a help menu and i want to connect it with
> a .txt file. in case 4 ý want to use fstream. how can i do it?
> thank you.
>
>
> #include <iostream>
> #include<string.h>
You don't use this header. Did you mean <string> or <cstring> (I'd hope
the former; see
http://parashift.com/c++-faq-lite/co...tml#faq-34.1)?
> using namespace std;
>
> int main()
> { char lang;
> int secim;
> int n;
> int pid=1||2||3||4||5;
> int tid=1||2;
> int amount;
This isn't C -- there's no need to declare all your variables up front.
Declare them only when you need them and can initialize them.
>
> cout<<"* INVENTORY MANAGEMENT SYSTEM *"<<endl;
> cout<<"* [1] Product operations *"<<endl;
> cout<<"* [2] Depot operations *"<<endl;
> cout<<"* [3] Stock maintanence *"<<endl;
> cout<<"* [4] Help *"<<endl;
> cout<<"* [5] Exit *"<<endl;
>
> cout<<"***********************************"<<endl;
> cout<<"Enter your choice from above MENU:"<<endl;
For instance, move "int secim;" here.
> cin>>secim;
>
> switch(secim){
> case 3:
>
> cout<<"* Inventory management system *"<<endl;
> cout<<"***********************************"<<endl;
> cout<<"* STOCK MAiNTANENCE *"<<endl;
> cout<<"Enter depotid="<<endl;
> cin>>tid;
> if(tid!=1||2)
> cout<<"\a\a\a invalid depotid,please enter correct id"<<endl;
> cin>>tid;
>
> cout<<"Enter productid="<<endl;
> cin>>pid;
> if(pid!=1||2||3||3||4||5)
This is legal but won't do what you want. Try
if(pid!=1 && pid!=2 && pid!= 3 && pid !=4 || pid != 5)
or better:
if( pid < 1 || pid > 5 )
> cout<<"\a\a\a invalid productid,please enter correct product
Ok, but after this print, you need to ask the user to enter it again,
restart the loop (lookup the continue keyword), exit, or something
other than simply proceeding onward as though there was no error.
> id"<<endl;
> cin>>pid;
>
> cout<<"Enter transaction amount="<<endl;
> cin>>amount;
>
> break;
>
>
>
> case 5:
>
> cout<<"Are you sure quit or continue"<<endl;
> cin>> lang;
> if(lang=='q'||lang=='Q')
> break;
> system("cls");
>
> if(lang=='c'||lang=='C')
> system("start");
> }
> return 0;
> }
If you just want to dump a text file to the screen, you could do:
ifstream file( "help.txt" );
string s;
while( getline( file, s ) )
{
cout << s << '\n';
}
There are other, more efficient ways to do it, but this way is probably
the more understandable for you. Alternately, just hard code it (either
in a constant or as an inline constant), e.g.,
cout << "Help text goes here\n"
"The next line goes here\n"
"The last line goes here\n";
Cheers! --M