473,770 Members | 6,322 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 2895
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
36542
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
7498
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
4217
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
3631
by: ma740988 | last post by:
Consider: #include <iostream> #include <sstream> #include <string> int main ( ) { { double pi = 3.141592653589793238; std::stringstream a;
2
21265
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
3606
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
9591
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
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10053
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...
0
9867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
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
5312
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
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3969
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

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.