473,787 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Watcom printf to stdout, I don't get it :-(

Sorry, I found a lot of old stuff, even kind of flamewars about
good+bad style whatsoever..

I simply want any hint that works!

I try to migrate older stuff from NT and newer stuff from Linux/AIX to
run on Windows2003 as well. I use the
Open Watcom C32 Optimizing Compiler Version 1.3
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.

I simply want some lines to be printed to stdout directly, like a
simple hello.c consisting of basically
printf("my text\n");

This is only printed when I call the programm with a redirection
("hello | tee x" or "hello > x"). The problem is mentioned a lot here
in older comp.* messages. But all the "soultions" I found+tried didn't
work as well.

I tried alternatively:

fflush(stdout);
getch();
getchar();
AFTER the printf, and

setvbuf(stdout, NULL,_IONBF,0);
BEFORE that line

and even
fprintf(stderr, "my text\n");
because I read somewhere stderr would never be buffered...?

So if there is someone with the patience to explain what to do I could
stick to watcom. Otherwise I'd have to throw it away and look for
something else...

Thanks a lot,
bine
Nov 14 '05 #1
1 2453
On 28 Jan 2005 07:56:32 -0800, sa************* *********@sunga rd.de
(bine) wrote:
Sorry, I found a lot of old stuff, even kind of flamewars about
good+bad style whatsoever..

I simply want any hint that works!

I try to migrate older stuff from NT and newer stuff from Linux/AIX to
run on Windows2003 as well. I use the
Open Watcom C32 Optimizing Compiler Version 1.3
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Questions about specific compilers and implementations are off-topic
here. The Watcom compiler defaults to fully buffered output, but I
think that fact is misleading you in this case.
I simply want some lines to be printed to stdout directly, like a
simple hello.c consisting of basically
printf("my text\n");

This is only printed when I call the programm with a redirection
("hello | tee x" or "hello > x"). The problem is mentioned a lot here
in older comp.* messages. But all the "soultions" I found+tried didn't
work as well.

I tried alternatively:

fflush(stdout) ; This should work.getch();
getchar(); These have no applicability here.AFTER the printf, and

setvbuf(stdout ,NULL,_IONBF,0) ; This should work if used *before* the first I/O to stdout.BEFORE that line

and even
fprintf(stderr ,"my text\n");
because I read somewhere stderr would never be buffered...? This should work.
So if there is someone with the patience to explain what to do I could
stick to watcom. Otherwise I'd have to throw it away and look for
something else...

My suspicion is that you have something wrong in your program, or you
are seeing a phenomenon due to your OS, since the suggested solutions
should have eliminated the Watcom buffering peculiarity. Did you check
the return value of the functions (fflush, setvbuf, printf) that you
used? Post the smallest compilable example which demonstrates the
problem, and we'll take a look at it.

--
Al Balmer
Balmer Consulting
re************* ***********@att .net
Nov 14 '05 #2

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

Similar topics

8
5055
by: Johan | last post by:
Hi, Where can I find the source for printf ? John
17
2810
by: G Patel | last post by:
E. Robert Tisdale wrote: > > int main(int argc, char* argv) { > quad_t m = {0, 1, 2, 3}; > int r; > fprintf(stdout, "m = ("); > for (size_t j = 0; j < 4; ++j) Why did you declare j as type size_t ?
12
1822
by: drM | last post by:
I have looked at the faq and queried the archives, but cannot seem to be able to get this to work. It's the usual factorial recursive function, but that is not the problem. It hangs after the user enters a number. However, as I indicate, if one adds something else after the number, the function proceeds and finishes successfully. I would appreciate some helpful hints. thanks in advance. >>>>>>>>>
2
1585
by: bine | last post by:
Sorry, I wanted to post a followup to my own question, but google was "Unable to retrieve message 003lv0h2n87mc764odt16i56btesds6dm9@4ax.com" ... I found a solution for printf directly, without fflush or setvbuf or other workarounds/addons. It was my fault, because I was using some of the samples\*..\makefile which had system nt_win inside, instead of nt (or 386) only. So in fact I created a win-compilation to use from a DOS-box or...
4
1849
by: I_have_nothing | last post by:
Hi! Is there any easy way to printf an integer in a way like 1,234,567? I know "%d" can be usd to print it as 1234567. Any type field in format specification can do that? Or any easy way to do that? How about to do that same thing in float type? such as make 987564321.85 into 987,564,321.85 ?
8
15498
by: jchludzinski | last post by:
Is there a format specification for printf that will result in: 1000000 being printed as 1,000,000? Or 1000000.0 as 1,000,000.0? ---John
8
4447
by: pemo | last post by:
I've just been trying out the Watcom compiler from http://www.openwatcom.org, and almost immediately compiled some working source that errored. The code is char buffer; ...
4
6143
by: user | last post by:
Hi, I am extending python with C and trying to debug with printf. The code below succssfully returns the string "hello" when compiled and called, but the "can print from in here phrase" does not reach python stdout. Is there something screwy with my environment or is there some trick to this that I don't know. Any help would be greatly appreciated!
10
4573
by: Rahul | last post by:
Hi Everyone, I had a query reg printf(). I heard that it can't be used in ISR's as it is non-re-enterant. I didn't get as to why printf is non-re-enterant and why non-re-enterant library can't be used in an ISR? Thanks in advance ! ! !
0
9655
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...
1
10110
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,...
0
9964
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
8993
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
7517
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
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
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
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.