Computer Science Canada

can't make new directory.

Author:  Geminias [ 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();
}

Author:  wtd [ Thu Nov 17, 2005 7:37 pm ]
Post 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?

Author:  Geminias [ Thu Nov 17, 2005 7:53 pm ]
Post 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.

Author:  wtd [ Thu Nov 17, 2005 7:56 pm ]
Post subject: 

You will find that very few languages will let you create directories so easily.

Author:  wtd [ Thu Nov 17, 2005 7:57 pm ]
Post 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.

Author:  Geminias [ Thu Nov 17, 2005 8:14 pm ]
Post subject: 

appreciate the tip wtd. I hope I can find it Wink

Author:  Geminias [ Thu Nov 17, 2005 8:34 pm ]
Post subject: 

hey wtd check this out.

Click here: <a href="http://www.justinmoser.bravehost.com">Me</a>

Author:  wtd [ Thu Nov 17, 2005 8:35 pm ]
Post subject: 

And why would I care about Microsoft's website?

Author:  Geminias [ Thu Nov 17, 2005 8:36 pm ]
Post subject: 

check now Laughing

Author:  wtd [ Thu Nov 17, 2005 8:43 pm ]
Post subject: 

Congrats. You have a fine grasp on 1995-era web design.

Author:  Geminias [ Thu Nov 17, 2005 8:46 pm ]
Post subject: 

i'm not finding anything relevant under boost library Sad

Author:  Geminias [ Thu Nov 17, 2005 8:47 pm ]
Post subject: 

thanks, i'm glad you like my skills

Author:  wtd [ Thu Nov 17, 2005 8:51 pm ]
Post subject: 

Google for "c++ boost library directory".

The first hit is this.

Author:  Geminias [ Thu Nov 17, 2005 8:52 pm ]
Post subject: 

okay i think i found it.. thanks anways


: