I am using Dev-C++ 4.9.8. The console stop after executing "cout << "Written
one iteration" << endl;".
Instructions in "if (! myFile){}" test is not run.
Thanks.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int i;
char c;
ofstream myFile("LPT1:") ;
// ofstream myFile("c:/out.txt");
// Creates an ofstream object named myFile
if (! myFile) // Always test file open
{
cout << "Error opening output file" << endl;
return -1;
}
for(i = 0; i < 5; i++) {
// c = getc();
c = 1;
cout << "Written one iteration" << endl;
myFile << c << endl;
}
myFile.close();
return 0;
} 6 2358
On Thu, 17 Mar 2005, Sea Squid wrote: I am using Dev-C++ 4.9.8. The console stop after executing "cout << "Written one iteration" << endl;". Instructions in "if (! myFile){}" test is not run.
Thanks.
#include <iostream> #include <fstream> using namespace std;
int main() { int i; char c; ofstream myFile("LPT1:") ; // ofstream myFile("c:/out.txt"); // Creates an ofstream object named myFile
if (! myFile) // Always test file open { cout << "Error opening output file" << endl; return -1; }
for(i = 0; i < 5; i++) { // c = getc(); c = 1; cout << "Written one iteration" << endl; myFile << c << endl; }
myFile.close();
return 0; }
I wonder if your problem is that you are trying to write the
character 1 to the file. This is translanslated in ASCII to SOH (Start of
heading), and I think it might be illegal to write it directly to a file.
I haven't actually tested it, but i remember having a similar problem a
few years ago.
Regards,
Reidar
Thank you for your reply.
Changing that line to the following doesnt help either.
My parallel port is empty, but I can see it in the hardware profile.
myFile << "test" << endl;
"Reidar Øksnevad" <re******@ifi.u io.no> wrote in message
news:Pi******** *************** *******@kaksi.i fi.uio.no... On Thu, 17 Mar 2005, Sea Squid wrote:
I am using Dev-C++ 4.9.8. The console stop after executing "cout <<
"Written one iteration" << endl;". Instructions in "if (! myFile){}" test is not run.
Thanks.
#include <iostream> #include <fstream> using namespace std;
int main() { int i; char c; ofstream myFile("LPT1:") ; // ofstream myFile("c:/out.txt"); // Creates an ofstream object named myFile
if (! myFile) // Always test file open { cout << "Error opening output file" << endl; return -1; }
for(i = 0; i < 5; i++) { // c = getc(); c = 1; cout << "Written one iteration" << endl; myFile << c << endl; }
myFile.close();
return 0; }
I wonder if your problem is that you are trying to write the character 1 to the file. This is translanslated in ASCII to SOH (Start of heading), and I think it might be illegal to write it directly to a file.
I haven't actually tested it, but i remember having a similar problem a few years ago.
Regards, Reidar
"Sea Squid" <Se*******@hotm ail.com> schrieb im Newsbeitrag news:42******@n ews.starhub.net .sg... I am using Dev-C++ 4.9.8. The console stop after executing "cout << "Written one iteration" << endl;". Instructions in "if (! myFile){}" test is not run. Thanks. #include <iostream> #include <fstream> using namespace std; int main() { int i; char c; ofstream myFile("LPT1:") ;
[...]
Did you swith on your printer (or whatever is connected to LPT1)?
Heinz
No. I didn't connect anything to the parallel port.
"Heinz Ozwirk" <ho**********@a rcor.de> wrote in message
news:42******** *************** @newsread4.arco r-online.net...
"Sea Squid" <Se*******@hotm ail.com> schrieb im Newsbeitrag
news:42******@n ews.starhub.net .sg... I am using Dev-C++ 4.9.8. The console stop after executing "cout <<
"Written one iteration" << endl;". Instructions in "if (! myFile){}" test is not run.
Thanks.
#include <iostream> #include <fstream> using namespace std;
int main() { int i; char c; ofstream myFile("LPT1:") ;
[...]
Did you swith on your printer (or whatever is connected to LPT1)?
Heinz
"Sea Squid" <Se*******@hotm ail.com> wrote in message
news:42******** @news.starhub.n et.sg... No. I didn't connect anything to the parallel port.
Put code in the loop to check the state of the stream. It may go into an
error state if you write to it when nothing is hooked up there. (Just
guessing.)
-Howard
(BTW, please put your responses after the text you are responding to, or
interspersed with it if appropriate. Newsgroup messages are read
top-to-bottom, so having your answer at the top is confusing to many of us.)
"Sea Squid" <Se*******@hotm ail.com> schrieb im Newsbeitrag news:42******** @news.starhub.n et.sg... No. I didn't connect anything to the parallel port.
Some systems are really slow to detect a missing device. Give it some time - or map LPT1 to some file or print-queue. But that's not a C++ problem.
Heinz This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stephen S M WONG |
last post by:
As C++ program supports objects with
constructors/destructors/methods and data items, I'll assume
C++ implementation on segment model computer, like a 80286
with different access restrictions on code segment / data
segment / etc., will force all objects to be resided in a
code segment, so that executable code can be there as well
as data. And effectively bypassing all segment model.
Any comments on the above?
|
by: LenS |
last post by:
If this is the wrong place to post this, please advise better place.
Otherwise, I have created the following python program and it works.
Running on XP. I think I am now at that stage of learning python where
I'm not quit a newbie and I am not really knowlegable. I know just
enough to be dangerous and can really screw things up.
Any suggestion on improving would be greatly appreciated. However my
real question is I would like to run...
|
by: MLH |
last post by:
I would like to modify the following Access Basic code in Access 2.0
app so the field would an automatic counter-type field.
Dim DefaultWorkspace As WorkSpace, CurrentDatabase As Database
Dim MyTableDef As TableDef
Dim MyField As Field
Set DefaultWorkspace = DBEngine.Workspaces(0)
Set CurrentDatabase = DefaultWorkspace.Databases(0)
Set MyTableDef = CurrentDatabase.CreateTableDef("tblTempTable")
Set MyField =...
|
by: madhur |
last post by:
Hello
char *a="str";
strcpy(a,"abc");
I have learnt that since "a" is a string literal, it might be allocated on
read only memory on some implementations.
Is it correct to modify a string literal using this way.
Madhur Ahuja
|
by: Skybuck Flying |
last post by:
Hi,
I needed a method to determine if a point was on a line segment in 2D. So I
googled for some help and so far I have evaluated two methods.
The first method was only a formula, the second method was a piece of C code
which turned out to be incorrect and incomplete but by modifieing it would
still be usuable.
The first method was this piece of text:
| |
by: Snis Pilbor |
last post by:
Hi,
It seems pretty common to return pointers to a static array, for
example:
char *capitalize( char *name )
{
static char buf;
sprintf( buf, "%s", name );
|
by: Eric_Dexter |
last post by:
I was trying to add this to my project but I must be missing some
includes or there is a serius error somewhere
Anthra Norell wrote:
|
by: raghu |
last post by:
Can anyone please tell me what are the different segments in a C
program? Where can I find more details regarding this?
Please help.
Merry Christmas and Happy New Year
Regards,
Raghu
|
by: Anonymous |
last post by:
Came across some code summarized as follows:
char const* MyClass::errToText(int err) const
{
switch (err)
{
case 0: return "No error";
case 1: return "Not enough";
case 2: return "Too much";
default: return "Unknown error";
|
by: jesjak |
last post by:
hi all,
can any one give me some explanation of "wat is .bss segment in object
file" and what it will contain and difference between data segment
and .bss segment....
help me....
thanks,
jes
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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: 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...
| |