Author |
Message |
Geminias
|
Posted: Thu Nov 17, 2005 7:29 pm Post subject: can't make new directory. |
|
|
for some reason i can't get it to make a new directory, or write a new file anywhere but the current one for that matter.
anyone know how to fix this?
here's the code i'm working with.
c++: |
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
char str[10];
//Creates an instance of ofstream, and opens example.txt
ofstream a_file ( "c:\\Program Files\\hello\\example.txt" );
// Outputs to example.txt through a_file
a_file<<"This text will now be inside of example.txt";
// Close the file stream explicitly
a_file.close();
//Opens for reading the file
ifstream b_file ( "c:\\Program Files\\hello\\example.txt" );
//Reads one string from the file
b_file>> str;
//Should output 'this'
cout<< str <<"\n";
// b_file is closed implicitly here
cin.ignore(1,'\n');
cin.ignore();
}
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
wtd
|
Posted: Thu Nov 17, 2005 7:37 pm Post subject: (No subject) |
|
|
First thing:
You're writing C++, not C. Don't use char arrays as strings.
Secondly...why do you think your program should be able to automagically create a new directory when it tries to create a new file? |
|
|
|
|
|
Geminias
|
Posted: Thu Nov 17, 2005 7:53 pm Post subject: (No subject) |
|
|
I didnt write the code. You already told me not to use character arrays.
Secondly, in turing I just add path ("c:whater") and it will accomplish the feet. It was only logical for me to attempt the same format in c++ while crossing my fingers and hoping it would work. |
|
|
|
|
|
wtd
|
Posted: Thu Nov 17, 2005 7:56 pm Post subject: (No subject) |
|
|
You will find that very few languages will let you create directories so easily. |
|
|
|
|
|
wtd
|
Posted: Thu Nov 17, 2005 7:57 pm Post subject: (No subject) |
|
|
Why? Well... part of it is because C++ is designed for half a gajillion different OSes and hardware platforms. Coming up with one library that deals with them all would be quite an undertaking.
You may wish to google for information about the boost libraries. |
|
|
|
|
|
Geminias
|
Posted: Thu Nov 17, 2005 8:14 pm Post subject: (No subject) |
|
|
appreciate the tip wtd. I hope I can find it |
|
|
|
|
|
Geminias
|
Posted: Thu Nov 17, 2005 8:34 pm Post subject: (No subject) |
|
|
hey wtd check this out.
Click here: Me |
|
|
|
|
|
wtd
|
Posted: Thu Nov 17, 2005 8:35 pm Post subject: (No subject) |
|
|
And why would I care about Microsoft's website? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Geminias
|
Posted: Thu Nov 17, 2005 8:36 pm Post subject: (No subject) |
|
|
check now |
|
|
|
|
|
wtd
|
Posted: Thu Nov 17, 2005 8:43 pm Post subject: (No subject) |
|
|
Congrats. You have a fine grasp on 1995-era web design. |
|
|
|
|
|
Geminias
|
Posted: Thu Nov 17, 2005 8:46 pm Post subject: (No subject) |
|
|
i'm not finding anything relevant under boost library |
|
|
|
|
|
Geminias
|
Posted: Thu Nov 17, 2005 8:47 pm Post subject: (No subject) |
|
|
thanks, i'm glad you like my skills |
|
|
|
|
|
wtd
|
|
|
|
|
Geminias
|
Posted: Thu Nov 17, 2005 8:52 pm Post subject: (No subject) |
|
|
okay i think i found it.. thanks anways |
|
|
|
|
|
|