473,785 Members | 3,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

std::stringstre am

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::stringstre am stream;
stream << "C:\\Output\\Ou tput.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::stringstre am 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::stringstre am stream;
stream << "C:\\Output\\Ou tput.txt" << std::flush;
std::ofstream SaveFile(stream .str().c_str()) ;

The "C:\Output" must already exist?

Nov 5 '06 #1
1 2898
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::stringstre am stream;
stream << "C:\\Output\\Ou tput.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::stringstre am 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
36543
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
7499
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 = "value1" + " : " + "value2";
1
4905
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
4218
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
3633
by: ma740988 | last post by:
Consider: #include <iostream> #include <sstream> #include <string> int main ( ) { { double pi = 3.141592653589793238; std::stringstream a;
2
21269
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 <iostream.h>
7
3608
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 tho network to a client so that errors and debug messages can be displayed simultaneously anywhere. I tried to use a std::stringstream to do the job. I created the stringstream in main() and pass it as pointer into a few threads. Those threads...
7
13639
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
5906
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 up into individual elements. The elements can be strings, integers or floating point numbers. In the object where I break the line into elements I use a std::stringstream object to do the actual check:
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10151
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.