473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

std::stringstream

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::ofstream 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::ofstream 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::ofstream SaveFile(stream.str().c_str());

The "C:\Output" must already exist?

Nov 5 '06 #1
1 2864
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::ofstream 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::ofstream SaveFile(stream.str().c_str());

Just remove the C:/ part.

--
Daniel
Nov 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Giampiero Gabbiani | last post by:
Is it possible to reset a std::stringstream in order to reuse it once more? I tried with flush() method without any success... Thanks in advance Giampiero
2
by: Woodster | last post by:
I am using std::stringstream to format a string. How can I clear the stringstream variable I am using to "re use" the same variable? Eg: Using std::string std::string buffer; buffer =...
1
by: KidLogik | last post by:
Hello! I am using std::stringstream && std::string to parse a text file -> std::ifstream in; std::string s; std::streamstring ss; int n; I grab each line like so -> std::getline(in,s);
5
by: Marcin Kalicinski | last post by:
Is there a vectorstream class that implements the functionality similar to std::stringstream but with std::vector, not std::string? cheers, Marcin
5
by: ma740988 | last post by:
Consider: #include <iostream> #include <sstream> #include <string> int main ( ) { { double pi = 3.141592653589793238; std::stringstream a;
2
by: akitoto | last post by:
Hi there, I am using the std::stringstream to create a byte array in memory. But it is not working properly. Can anyone help me? Code: #include <vector> #include <sstream> #include...
7
by: Ziyan | last post by:
I am writing a C/C++ program that runs in background (Linux). Therefore, normally no output would be written into standard output. However, sometimes I want to have debug message collected and sent...
7
by: Grey Alien | last post by:
Does *ANYONE* in here know how I may parse the various date/time 'elements' from a string?. The input string has the ff format: 'YYYY-MM-DD HH:MM:SS AM'
3
by: Rune Allnor | last post by:
Hi all. I am trying to use std::stringstream to validate input from a file. The strategy is to read a line from the file into a std::string and feed this std::string to an object which breaks it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.