Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > std::stringstream

Reply
Thread Tools

std::stringstream

 
 
magix
Guest
Posts: n/a
 
      11-05-2006
I got this reply in my previous post a month ago:

May I know, how can I automatically create the folder if it doesn't exist ?
In previous reply, it said:
-------------------------
std::stringstream stream;
stream << "C:\\Output\\Output.txt" << std::flush;
std:fstream SaveFile(stream.str().c_str());

The "C:\Output" must already exist?
------------------------

What I prefer is:
- the folder (let say folder name is output) is created (if it doesn't
exist) at the same directory as the executables, the executes can be at any
directory, so we don't need to specifiy the full path

Anyone can help ?

Thanks.




magix wrote:
> Hi,
>
> I got following to savefile into Output.txt, but how can I specify it to
> be
> in specific folder/directory (not at the same directory as the
> executables?
> Currently, it will generate the output.txt under the same directory as the
> executables.
>
> std::stringstream stream;
> stream << "Output.txt" << std::flush;
> std:fstream SaveFile(stream.str().c_str());
>
>
> Example:
> C:\Programming\test input.txt
> it will generate output.txt in the same directory as where the executable
> "test" located
>
> If I want output.txt to be generated in C:\Programming\Output\ or at other
> directory i.e C:\Output\, how to achieve that ?
>
> Please help. Thanks.
>
> Regards.


std::stringstream stream;
stream << "C:\\Output\\Output.txt" << std::flush;
std:fstream SaveFile(stream.str().c_str());

The "C:\Output" must already exist?





 
Reply With Quote
 
 
 
 
=?iso-8859-1?Q?Lidstr=F6m?=
Guest
Posts: n/a
 
      11-05-2006
On Sun, 5 Nov 2006 12:29:50 +0800, magix wrote:

> I got this reply in my previous post a month ago:
>
> May I know, how can I automatically create the folder if it doesn't exist ?
> In previous reply, it said:
> -------------------------
> std::stringstream stream;
> stream << "C:\\Output\\Output.txt" << std::flush;
> std:fstream SaveFile(stream.str().c_str());
>
> The "C:\Output" must already exist?
> ------------------------
>
> What I prefer is:
> - the folder (let say folder name is output) is created (if it doesn't
> exist) at the same directory as the executables, the executes can be at any
> directory, so we don't need to specifiy the full path
>
> Anyone can help ?


Perhaps this?
std::stringstream stream;
stream << "Output/Output.txt" << std::flush;
std:fstream SaveFile(stream.str().c_str());

Just remove the C:/ part.

--
Daniel
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments