Quoting Noorez Kassam <coo...@ho...>:
> The marked program line in the loop is skipping on the first time aroun=
d. It
>=20
> is the cin.getline() function.
>=20
Where?=20
btw, noticed the line:
while(ask !=3D 'y' || ask !=3D 'Y' || ask !=3D 'n' || ask !=3D 'N')
this will always be true. (If ask =3D=3D 'y' then ask !=3D 'Y' ...)
> #include <iostream>
> #include <cstdlib>
> #include <direct.h>
> using namespace std;
>=20
> int system(bool cls);
> int main()
> {
> cout << "Easy to use dos-prompt!" << endl;
> cout << "\nTo switch dirves use this: drvswitch\n";
> cout << "\nTo quit you can use any one of the following commands: \n"
> << "quit, bye, exit\n";
>=20
> char ask;
>=20
> do
> {
> cout << "\nWould you like to enter the system? [Y\\N]";
> cin >> ask;
>=20
> if(ask =3D=3D 'y' || ask =3D=3D 'Y')
> {//main if
>=20
> cout << "\nYou can also have the program Clear Screen automaticly =
after
>=20
> each command.\n";
> cout << "Is this Ok [Y\\N] ";
>=20
> char cls;
> bool cLs;
> cin >> cls;
> if(cls =3D=3D 'y' || cls =3D=3D 'Y')
> {
> cLs =3D TRUE;
> }
>=20
> else if(cls =3D=3D 'n' || cls =3D=3D 'N')
> {
> cLs =3D FALSE;
> }
>=20
> else
> {
> cout << "What...";
> cout << "Default is set. No Clear Screen!\n";
> cLs =3D FALSE;
> }
> //return to main test
> system(cLs);
> system("pause");
> return 0;
> }
>=20
> else if(ask =3D=3D 'n' || ask =3D=3D 'N')
> {
> cout << "Bye!" << endl;
> system("pause");
> return 0;
> }
>=20
> else
> {
> cout << "What....\n" << endl;
> }
>=20
> }while(ask !=3D 'y' || ask !=3D 'Y' || ask !=3D 'n' || ask !=3D 'N');
>=20
> return 0;
> }
>=20
> //define the system function
> int system(bool cls)
> {
>=20
> drvswitch:
>=20
> char drv[8];
> cout << "\nEnter the name of the drive you want to go to: ";
> cin >> drv;
> strcat(drv,":");
> chdir(drv);
>=20
> cout << "Now in drive " << drv << "\\" << endl;
> cout << "You may type in commands" << endl;
> system("pause");
> strcat(drv,"\\>");
>=20
> char coms[123];
>=20
> while(1)
> {
> cout << drv;
> cin.getline(coms,124); //this is skipping
>=20
> if( strcmp(coms,"exit")=3D=3D0 || strcmp(coms,"bye")=3D=3D0 ||=20
> strcmp(coms,"quit")=3D=3D0 )
> {
> return 0;
> }
>=20
> if(strcmp(coms,"drvswitch")=3D=3D0)
> {
> goto drvswitch;
> }
>=20
> system(coms);
>=20
> if(cls =3D=3D TRUE)
> {
> system("pause");
> system("cls");
> }
>=20
> cout << endl;
> }//while
> }
>=20
> _________________________________________________________________
> The new MSN 8: smart spam protection and 2 months FREE* =20
> http://join.msn.com/?page=3Dfeatures/junkmail =20
>
http://join.msn.com/?page=3Ddept/bcomm&pgmarket=3Den-ca&RU=3Dhttp%3a%2f%2=
fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
>=20
>=20
>=20
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=3D1356&alloc_id=3D3438&op=3Dclick
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
>=20
|