ok, i kinda feel like an idiot asking this, but here it goes

simple setup for example purposes.:


#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
system("cd\")
return 0;
}


ok, as you've prolly already noticed, the CD\ will return an error saying that there is an invalid terminator because of the "\" .. all i want to do is change directories lol.. can someone help me out. thnx

ok, now it says chdir is undefined... is there a header to accompany this function??

the escape character for a backslash is simply \\ - however, as Ancient Dragon says, CD\\ (or indeed any system() call) is unsafe. IIRC, chdir() is part of windows.h or conio.h depending on your implementation - it's not a standard header, but it's certainly better than system().

i appreciate the help, but it still is not working...
heres the setup i have right now

#include <stdio.h>
#include <windows.h>
#include <conio.h>

using namespace std;

int main()
{
chdir("C:\\");

return 0;

}


still says chdir is undeclared

ok i finally figured it out.. it was a header file indeed..
except it was #include<unistd.h>

thnx for the pointer.. Pe@cE

This article has been dead for over six months. Start a new discussion instead.