|
|
|
|
Bonjour,
je fais présentement un programme semblable à cmd.exe de Windows pour mon plaisir, mais il ne fonctionne pas tout à fait.
#include <iostream>
#include <windows.h>
int main
{
char[50] inst=NULL; // L'instruction (ex: help ou shutdown/s dans cmd.exe .
bool exit=false; //Booléen qui détermine si la boucle continue ou pas.
while(!exit) //tant que "exit" est faux.
{
cout <<"...";
cin <<"inst"; //Demande à l'utilisateur une instruction
if(inst==exit)
{
cout << "bye";
exit=true;
}
else if ...
...
...
}
return 0
}
Configuration: Windows Vista Ultimate SP1 Firefox 3.0.7 Code::Blocks
Salut,
|
OK merci je vais verifier
|
J'ai modifié mon else car il était erroné , maintenant mon programme me dit toujours que la commande est incorrecte.
|
Ok voici le code complet... attention il est facile de se perdre (je suis TRES désorganisé)
#include <iostream>
#include <windows.h>
using namespace std;
char inst[50];
bool pexit=false;
int main()
{
char inst[50];
bool pexit=false;
while(!pexit)
{
cout << ".../$USR/$Dir/LAB.EXE:>";
cin >> inst;
if(inst=="exit")
{
pexit=true;
break;
}
else if(inst=="help")
{
cout << "Note:commands are case sensitive! \n help: Gives this \n exit: shut down the program \n info: gives information about the program."<< endl;
cout << "texit: shutsdown the program after an amount of time \n wexit: Shuts down windowa "<<endl;
break;
}
else if(inst=="info")
{
cout << " Written by Gabriel Arsenault in C++." <<endl;
break;
}
else if(inst=="wexit")
{
cout << "Windows will shutdown 5 seconds after you receive a confirmation" <<endl;
system("Shutdown.exe -r -m @IP -t 5 -c \"Command confirmed...\"");
break;
}
else if(inst=="EntertheSandman")
{
cout << "Eeeexiiiit liiight... :P" << endl;
pexit=true;
cout << "Variable \" exit \" has been changed to true" <<endl;
Sleep(750);
cout << "Bye" <<endl;
break;
}
else if(inst=="revealyoursecret")
{
cout << " I swear my intentions are evil... \n Made by Gabriel Arsenault for devil 122 in association with joe prank 2333" << endl;
break;
}
else if(inst=="texit")
{
char time;
time=0;
cin >> time;
Sleep(time);
pexit=true;
break;
}
else
{
cout << " Instruction incorrect." <<endl;
}
}
return 0;
}
:P note: Le programme n'est pas terminé , alors les fonctions décrites dans help ne sont pas toutes vraies |
Effectivement lol.
|
la compilation plantait toujours
|
Avec string la compilation plante... ça me dit qu'il manque une instruction quelque-pat quelque-chose su genre... c'était pas dans CE programme...
if(nomdestring=="Bou!")
{
cout << "Ah!!" <<endl;
}
? |