473,326 Members | 2,126 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,326 software developers and data experts.

repeatedly trying to open a file

Hi!

I feel I must be missing something simple.

I want a program to try and open a file stream. If it fails it allows
the user the
chance to try again.

Usually a file stream is opened in the constructor

void save_file ()
{
do
{
ostream os ("test.dat");

if (!os)
{
if (!try_again())
return;
}
} while (!os)

os << stuff;
}

but os has gone out of scope... Do osteams have an open() method?
I did look in a couple of places...
--
Nick Keighley

Physics, as we know it, will be over in six months.
Max Born (1928)

Nov 22 '06 #1
1 1276
Nick Keighley wrote:
>
but os has gone out of scope... Do osteams have an open() method?
I did look in a couple of places...
ostreams do not have an open member function - they don't deal with
files. ofstreams, however, do.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Nov 22 '06 #2

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

Similar topics

14
by: Michael Levin | last post by:
I've got the following problem. I'm a biologist and I have a device at work which monitors my frog habitat. The device has a bunch of sensors, and runs an embedded html server with some java...
12
by: Ron Weldy | last post by:
I have a test server runinng 2003/IIS 6 with a mixture of asp and asp.net files. On my workstation I have a share set up to the folder where the web files reside. I am just doing quick and dirty...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
13
by: Richard Shewmaker | last post by:
I've only recently returned to (trying to) doing simple JS, so this is probably a really lame question. I have a Web page with a series of graphics in it (window A). Clicking on a graphic in A...
13
by: cj | last post by:
Stephany Young provided me with the following code to count threads created by my program. Public Class MyThreadCount Private Shared m_lock As New Object Private Shared m_threadcount As Int32...
0
by: UJ | last post by:
I am trying to write a routine to upload a file through a web service to our server. I've enclosed the following code and when I run it I get an error: Exception Occurred. Error: Logon failure:...
16
by: John U. | last post by:
Hi Group, Here is a common problem: I have many (100) links on a web page, all pointing to different pages on the same domain (e.g., "http:// www.x12345.com/"). This is a bother because (1)...
3
by: Max58kl | last post by:
Trying to access data and print it to the screen using Perl Builders I/O Window -------------------------------------------------------------------------------- Hi I am using a program called...
5
by: mbewers1 | last post by:
I have a problem with this piece of code, which loads a splash screen and keeps it open for 5 seconds before loading another form. It strangely seems to be repeatedly running a thread once the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.