#include <cstdlib>
#include <iostream>
usingnamespace std;
int main()
{
int site;
cout<<"Desired web-sites :\n";
cout<<"1- Facebook\n";
cout<<"2- Google\n";
cout<<"3- EUHackers Official Site\n";
cout<<"4- XxX Eagles XxX Official Site\n";
cout<<"Push one of the disred numbers then press enter to open it\n";
cout<<" \n";
cout<<" \n";
cout<<"Your desired web-site number is : ";
cin>> site;
cin.ignore();
if ( site == 1 ) {
system("START http://www.cplusplus.com/forum/beginner/88318/");
cout<<" \n";
cout<<"Website has been open succesfully!";
cout<<" \n\n";
cout<<"Please input another number to continue : ";
}
elseif( site == 2 ) {
system("START http://www.cplusplus.com/forum/beginner/88318/");
cout<<" \n";
cout<<"Website has been open succesfully!";
cout<<" \n\n";
cout<<"Please input another number to continue : ";
}
elseif ( site == 3 ) {
system("START http://www.cplusplus.com/forum/beginner/88318/");
cout<<" \n";
cout<<"Website has been open succesfully!";
cout<<" \n\n";
cout<<"Please input another number to continue : ";
}
elseif( site == 4 ) {
system("START http://www.cplusplus.com/forum/beginner/88318/");
cout<<" \n";
cout<<"Website has been open succesfully!";
cout<<" \n\n";
cout<<"Please input another number to continue : ";
}
else {
cout<<" \n\n\n";
cout<<"You have entred invalid number.\n";
cout<<"Please enter another VALID number : ";
}
cin.get();
}
When i press a number , it open the page well , but if i press another number for second time , it get closed . Help me with this please :(
#include <iostream>
int main()
{
// ...
int site ;
do
{
std::cout << "enter one of the numbers (or -1 top quit): " ;
while( !( std::cin >> site ) )
{
std::cout << "please enter a number: " ;
std::cin.clear() ;
std::cin.ignore(1000,'\n') ;
}
switch( site )
{
case 1 :
/* open site 1 */
break ;
case 2 :
/* open site 2 */
break ;
// etc ..
}
} while( site != -1 ) ;
}
#include <cstdlib>
#include <iostream>
usingnamespace std;
int main()
{
int site ;
cout<<"Auto opener :\n";
cout<<"1- Garena Plus download\n";
cout<<"2- DotA 6.77 changelogs\n";
cout<<"3- DotA 6.77 download\n";
cout<<"4- Warcraft 1.26 patch download\n";
cout<<"5- Ven.detta official site\n\n";
cout<<"Push one of the desired numbers then press enter to open it\n";
cout<<" \n";
cout<<" \n";
do
{
std::cout << "Please enter one of the numbers to continue or -1 to quit: ";
while( !( std::cin >> site ) )
{
std::cout << "You have entred an invalid character !\n\n" ;
std::cout << "Please enter one of the numbers to continue or -1 to quit: ";
std::cin.clear() ;
std::cin.ignore(1000,'\n') ;
}
switch( site )
{
case 1 :
system("start http://universal-downloader.en.softonic.com/95000/95079/ud_200/SoftonicDownloader_for_garena.exe");
cout<<" \n";
cout<<"Website has been open succesfully!";
cout<<" \n\n";
break ;
case 2 :
system("start http://www.playdota.com/changelogs/6.77");
cout<<" \n";
cout<<"Website has been open succesfully!";
cout<<" \n\n";
break ;
case 3 :
system("start http://static.getdota.com/maps/eng/DotA%20v6.77.w3x");
cout<<" \n";
cout<<"Website has been open succesfully!";
cout<<" \n\n";
break ;
case 4 :
system("start http://ftp.blizzard.com/pub/war3x/patches/pc/War3TFT_126a_English.exe");
cout<<" \n";
cout<<"Website has been open succesfully!";
cout<<" \n\n";
break ;
case 5 :
system("start http://ven-detta.tk");
cout<<" \n";
cout<<"Website has been open succesfully!";
cout<<" \n\n";
break ;
}
} while( site != -1 ) ;
}
> i just want an error message when you don't put one of the numbers from 1 to 5 ..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
switch( site )
{
case 1 :
// ...
break ;
case 2 :
// etc upto case 5
case -1 :
break ;
default:
// print error message
// the number entered is not one of the numbers from 1 to 5 .. or -1
}
} while( site != -1 ) ;
case 8 :
system("exit");
break;
default :
cout<<"\n|--|The number you entred is wrong !|--|\n\n";
break ;
}
} while( site != -1 ) ;
}
IDK if you meant this , this is what i done and when i press 8 nothing happen , it just ask like normal to put another number in it ( NOT WRONG NUMBER ERROR )