chdir() is quite good at changing directories.
When you fork another program - as you do with system("xx") - and have
it change directory, that doesn't change the directory for your program.
/Per W
On Fri, 13 Feb 2004, Noorez Kassam wrote:
> Just for the fun of it i made this prompt thing but it doesn't switch
> directories? Can you see how i can get it to do it?
>
>
>
> #include <iostream>
> #include <cstdlib>
> using namespace std;
>
> int system();
> int main()
> {
> cout << "Easy to use dos-prompt!" << endl;
> cout << "To switch dirves use this: drvswitch\n" << endl;
> char ask;
>
> do
> {
> cout << "Would you like to enter the system? [Y\\N]";
> cin >> ask;
>
> if(ask == 'y' || ask == 'Y')
> {
> system();
> system("pause");
> return 0;
> }
>
> else if(ask == 'n' || ask == 'N')
> {
> cout << "Bye!" << endl;
> system("pause");
> return 0;
> }
>
> else
> {
> cout << "What....\n" << endl;
> }
>
> }while(ask != 'y' || ask != 'Y' || ask != 'n' || ask != 'N');
>
> return 0;
> }
>
> //define the system function
> int system()
> {
> drvswitch:
>
> cout << "What drive would you like to go to?";
> char drv[8];
>
> cin >> drv;
> strcat(drv,":");
>
> system(drv);
>
> cout << "Now in drive " << drv << endl;
> cout << "Type in commands: " << endl;
> strcat(drv,"\\>");
>
> char coms[123];
>
> while(1)
> {
> cout << drv;
> cin.getline(coms,124);
>
> if(strcmp(coms,"exit")==0)
> {
> return 0;
> }
>
> if(strcmp(coms,"drvswitch")==0)
> {
> goto drvswitch;
> }
>
> system(coms);
> cout << endl;
> }//while
> }
>
> _________________________________________________________________
> Add photos to your messages with MSN 8. Get 2 months FREE*.
> http://join.msn.com/?page=dept/features&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
>
>
>
> -------------------------------------------------------
> 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=1356&alloc_id=3438&op=click
> _______________________________________________
> 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
>
|