473,385 Members | 1,356 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,385 software developers and data experts.

Output to a control instead of the MS Dos box for C programs

Hello all,

I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.

Has C the possibility to do printouts to a control instead of using the
MS Dos Box? And what control can I use for this purpose when I need to
have the most similar look to the MS Dos Box?

Every help is greatly appreciated.
Thanks in advance.

With kind regards,
Tiziana

Nov 7 '06 #1
24 1972
In article <11**********************@m73g2000cwd.googlegroups .com>,
tizi_de <ti*************@web.dewrote:
>Hello all,

I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.

Has C the possibility to do printouts to a control instead of using the
MS Dos Box? And what control can I use for this purpose when I need to
have the most similar look to the MS Dos Box?
Off topic. Not portable. Cant discuss it here. Blah, blah, blah.

Useful clc-related links:

http://en.wikipedia.org/wiki/Aspergers
http://en.wikipedia.org/wiki/Clique
http://en.wikipedia.org/wiki/C_programming_language

Nov 7 '06 #2
On 7 Nov 2006 03:03:37 -0800, "tizi_de" wrote:
>I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.
Has C the possibility to do printouts to a control instead of using the
MS Dos Box?
Of course, don't you know that you can do anything in C?
>And what control can I use for this purpose when I need to
have the most similar look to the MS Dos Box?
Write your output to a file with extension *.html and the following
structure:

<html>
<body>
<pre>

// your output here

</pre>
</body>
</html>

Open that file in/with your browser.

Good luck,
Roland Pibinger
Nov 7 '06 #3
tizi_de wrote:
I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.

Has C the possibility to do printouts to a control instead of using the
MS Dos Box? And what control can I use for this purpose when I need to
have the most similar look to the MS Dos Box?
try comp.os.ms-windows.programmer.win32 where you might get better
answers.
Ignore Kenny he's the group idiot.
--
Nick Keighley

Nov 7 '06 #4
tizi_de wrote:
>
I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.

Has C the possibility to do printouts to a control instead of using
the MS Dos Box? And what control can I use for this purpose when I
need to have the most similar look to the MS Dos Box?
See the links below.

--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt>
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/(C99)
<http://www.dinkumware.com/refxc.html (C-library}
<http://gcc.gnu.org/onlinedocs/ (GNU docs)
<http://clc-wiki.net (C-info)
Nov 7 '06 #5
Nick Keighley said:

<snip>
Ignore Kenny he's the group idiot.
With the greatest respect, Nick, I cannot agree with your choice of article.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 7 '06 #6
tizi_de a écrit :
Hello all,

I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.

Has C the possibility to do printouts to a control instead of using the
MS Dos Box? And what control can I use for this purpose when I need to
have the most similar look to the MS Dos Box?

Every help is greatly appreciated.
Thanks in advance.

With kind regards,
Tiziana
Many people have done that, a "printf" in a control.
It is not VERY hard to do, but maybe the simplest thing
is to create the control, then call SetWindowText with
the handle of the control and the text you want to put into it.
(I am assuming is a static text control or an edit field)

More sophisticated usages with scrolling, etc are more demanding and
you would have to reimplement the "Dos box" what is nothing else
than a window with scrolling in it.

jacob
Nov 7 '06 #7
jacob navia <ja***@jacob.remcomp.frwrites:
tizi_de a écrit :
>Hello all,
I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.
Has C the possibility to do printouts to a control instead of using
the
MS Dos Box? And what control can I use for this purpose when I need to
have the most similar look to the MS Dos Box?

Many people have done that, a "printf" in a control.
It is not VERY hard to do, but maybe the simplest thing
is to create the control, then call SetWindowText with
the handle of the control and the text you want to put into it.
[snip]

jacob's advice may be correct, but since he's not talking about
standard C, most of us here can't confirm or refute his information.

Tiziana: You need to post to a newsgroup that's specific to your
system. comp.os.ms-windows.programmer.win32 *might* be the right
place.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 7 '06 #8
jacob navia wrote:
tizi_de a écrit :
>>
I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.

Has C the possibility to do printouts to a control instead of using
the MS Dos Box? And what control can I use for this purpose when I
need to have the most similar look to the MS Dos Box?

Many people have done that, a "printf" in a control.
It is not VERY hard to do, but maybe the simplest thing
is to create the control, then call SetWindowText with
the handle of the control and the text you want to put into it.
Haven't you learned yet that SetWindowText and 'a control' have
nothing to do with standard C? Neither does a MS Dos Box, nor a
handle. Please stop cluttering this group with off-topic
foolishness.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Nov 7 '06 #9
CBFalconer wrote:
jacob navia wrote:
>>tizi_de a écrit :
>>>I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.

Has C the possibility to do printouts to a control instead of using
the MS Dos Box? And what control can I use for this purpose when I
need to have the most similar look to the MS Dos Box?

Many people have done that, a "printf" in a control.
It is not VERY hard to do, but maybe the simplest thing
is to create the control, then call SetWindowText with
the handle of the control and the text you want to put into it.


Haven't you learned yet that SetWindowText and 'a control' have
nothing to do with standard C? Neither does a MS Dos Box, nor a
handle. Please stop cluttering this group with off-topic
foolishness.
A handle is an opaque pointer.

Its definition can be expressed in standard see as:

struct window;

typedef struct window *WindowHandle; // Or HWND for short.

This is very common in windows systems, and since the Mac,
opaque pointers are part of the life of C programmers.

Nov 7 '06 #10

tizi_de <ti*************@web.dewrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hello all,

I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.

Has C the possibility to do printouts to a control instead of using the
MS Dos Box? And what control can I use for this purpose when I need to
have the most similar look to the MS Dos Box?
OFF TOPIC!!!
Every help is greatly appreciated.
Thanks in advance.

With kind regards,
Tiziana
But since you asked so nicely...

First off, I'm assuming you're talking about using something like
printf() to print to a Windows "control" rather than the actual function
found in the winapi (or equivalent) for printing to the control. To
do the latter, check your Windows API package documentation...

However, to do the former, sure, I do it all the time, but as
usual exactly how you code this depends on what you really
want and what you're starting off with...

Here's the basic trick though: you have to selectively
re-define "printf()" to "print" to the control as if it
were the "console" (what you're calling a "DOS Box", or
equivalently, an "xterm" in Unix). Here's how I do it,
but again, your mileage may vary:

#ifdef __WINGUI__
#include <vcl.h>
#pragma hdrstop
#include <p_output.h>
#define printf gui_printf
#endif

Now this assumes a couple of things. First, I'm using
a particular development package (so "vcl.h" may be
something else for you, or you are using the "winapi" package
available bone-stock free from Microsoft on their website, which
may be the best idea of all, frankly). Second, this
is clearly "dual-use" code; I can conditionally compile
it as either Windows GUI application or as a "console"
(or "xterm") command-line interface application.

So if I compile the thing as a Windows GUI application,
the pre-processor turns all occurences of printf() into
gui_printf(), which is declared in "p_output.h" and defined
in a file called "p_output.c" which is linked into your
program.

gui_printf() is declared with the exact same "signature"
as "printf()", and defined as follows:

int gui_printf(char *format,...) {
unsigned print_length;

p_line_buffer[0]=NUL;
va_list ap;

va_start(ap,format);
vsprintf(p_line_buffer,format,ap);
va_end(ap);

print_length=(int)strlen(p_line_buffer);

print_line_buffer();

return print_length;
}

Note that the trick here is the use of the "vsprintf()"
function to handle all the functionality of "printf()" without
the nasty consequence of actually sending the output to
the "console". Instead, the formatted output is "printed"
to a buffer, and then the buffer is "printed" to the
Windows control by the "print_line_buffer()" function.

Now this is where you have to figure out where you're
coming from and where you "want to go today". What "control"
do you "print" to? Well, it's been a while since I looked
directly at the winapi package, but I think it's called
the "memo" control. In any event, it's the one Microsoft
uses in "Notepad" for displaying and editing relatively
small (36K limit) text-only files (my development package
supplies a "visual component" class called "TMemo" that
I use for this purpose, so unless you use the same package
the calls and configuration of this "object" won't make
too much sense).

But you'll probably want to implement some type of "scrolling"
functionality to allow you to freely and asynchronously "print"
to the control in the same way that "printf()" prints to
the "console". One thing is for sure: if you use the "memo" control,
your program will blow up to smithereens if you exceed the 36K text
limit, so unless you are sure you won't exceed that amount of
text, you'll have to "scroll out" old text from the "memo" control
buffer in order to "scroll in" new text.

This actually can be implemented by creating a "console buffer"
that ties into the calls to the "memo" control (or whatever it's called),
but I think you'll always wind up with (I've wound up with) some
fairly small "flickering" when scrolling large amounts of text because
the control was not designed to scroll asynchronous amounts of
text in the first place, just display a discrete single block of text.

For me, it's OK, but I think to get rid of that artifact
completely, you would have to go back to scratch and
work with rudimentary calls like "WM_PAINT" or whatever
and build your own console "work-alike"...

---
William Ernest Reid

Nov 7 '06 #11
On 7 Nov 2006 03:03:37 -0800, in comp.lang.c , "tizi_de"
<ti*************@web.dewrote:
>Hello all,

I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.
Assuming you're using Windows, you need to ask in a Windows
programming group, GUI interfaces are not part of hte C language.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Nov 7 '06 #12
On Tue, 07 Nov 2006 22:51:51 +0100, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:
>
A handle is an opaque pointer.
So you claim. Its impossible to verify that here, since its not part
of standard C.

You /know/ this is offtopic, why are you persisting in being such a
jerk?
>This is very common in windows systems, and since the Mac,
opaque pointers are part of the life of C programmers.
So what? Cola and cake part of the life of C programmers. Are either
of those topical here?
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Nov 7 '06 #13
Mark McIntyre wrote:

So what? Cola and cake part of the life of C programmers. Are either
of those topical here?

I didn't know there was going to be cake today. What kind?


Brian
Nov 7 '06 #14
In article <r8********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.netwrote:
>On Tue, 07 Nov 2006 22:51:51 +0100, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:
>>
A handle is an opaque pointer.

So you claim. Its impossible to verify that here, since its not part
of standard C.

You /know/ this is offtopic, why are you persisting in being such a
jerk?
>>This is very common in windows systems, and since the Mac,
opaque pointers are part of the life of C programmers.

So what? Cola and cake part of the life of C programmers. Are either
of those topical here?
You guys really need to get a grip.

Nov 8 '06 #15
jacob navia <ja***@jacob.remcomp.frwrote:
tizi_de a écrit :
I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.

Has C the possibility to do printouts to a control instead of using the
MS Dos Box? And what control can I use for this purpose when I need to
have the most similar look to the MS Dos Box?

Many people have done that, a "printf" in a control.
It is not VERY hard to do, but maybe the simplest thing
is to create the control, then call SetWindowText with
the handle of the control and the text you want to put into it.

(I am assuming is a static text control or an edit field)
Not necessarily correct, and very unlikely to be sufficient. Thus jacob
proves once more both the inadvisability of answering off-topic
questions in comp.lang.c, and the lack of depth of his own knowledge.

Richard
Nov 8 '06 #16
CBFalconer wrote:
>
See the links below.

<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/(C99)
You could consider linking to n1124 , as there are important
differences between n869 and the actual C99 text.

Nov 8 '06 #17
Old Wolf wrote:
CBFalconer wrote:
>See the links below.

<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/(C99)

You could consider linking to n1124 , as there are important
differences between n869 and the actual C99 text.
However N1124 doesn't offer a text version. Bad.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Nov 9 '06 #18
CBFalconer <cb********@yahoo.comwrites:
Old Wolf wrote:
>CBFalconer wrote:
>>See the links below.

<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/(C99)

You could consider linking to n1124 , as there are important
differences between n869 and the actual C99 text.

However N1124 doesn't offer a text version. Bad.
Using Adobe Reader, I was able to load n1124.pdf and export it as
text. Other PDF readers can probably do the same thing. I haven't
really tried using the resulting text version; I just use the pdf.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 9 '06 #19
Keith Thompson <ks***@mib.orgwrites:
CBFalconer <cb********@yahoo.comwrites:
>Old Wolf wrote:
>>CBFalconer wrote:
See the links below.

<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/(C99)

You could consider linking to n1124 , as there are important
differences between n869 and the actual C99 text.

However N1124 doesn't offer a text version. Bad.

Using Adobe Reader, I was able to load n1124.pdf and export it as
text. Other PDF readers can probably do the same thing. I haven't
really tried using the resulting text version; I just use the pdf.
And Ghostview's seems to give a cleaner text conversion than Adobe
Reader does.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 9 '06 #20
Keith Thompson wrote:
CBFalconer <cb********@yahoo.comwrites:
>Old Wolf wrote:
>>CBFalconer wrote:
See the links below.

<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/(C99)

You could consider linking to n1124 , as there are important
differences between n869 and the actual C99 text.

However N1124 doesn't offer a text version. Bad.

Using Adobe Reader, I was able to load n1124.pdf and export it as
text. Other PDF readers can probably do the same thing. I haven't
really tried using the resulting text version; I just use the pdf.
I use the text version all the time. It is quickly and easily
searched and/or grepped. I modified the published version slightly
(reducing the lh margin, and stripping the page breaks) so it is
easily used for usenet quotes, etc. The result is bz2d, and
available on:

<http://cbfalconer.home.att.net/download/>

The results of a text dump from N1124 are virtually useless. So I
put up with the differences.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

Nov 9 '06 #21
2006-11-09 <45***************@yahoo.com>,
CBFalconer wrote:
Keith Thompson wrote:
>CBFalconer <cb********@yahoo.comwrites:
>>Old Wolf wrote:
CBFalconer wrote:
See the links below.
>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/(C99)

You could consider linking to n1124 , as there are important
differences between n869 and the actual C99 text.

However N1124 doesn't offer a text version. Bad.

Using Adobe Reader, I was able to load n1124.pdf and export it as
text. Other PDF readers can probably do the same thing. I haven't
really tried using the resulting text version; I just use the pdf.

I use the text version all the time. It is quickly and easily
searched and/or grepped. I modified the published version slightly
(reducing the lh margin, and stripping the page breaks) so it is
easily used for usenet quotes, etc. The result is bz2d, and
available on:

<http://cbfalconer.home.att.net/download/>

The results of a text dump from N1124 are virtually useless. So I
put up with the differences.
Has anyone tried making a "polished" text version of N1124? Would such
a thing be compatible with WG14's copyrights (though it seems to me that
if your modifications to n869 are ok, this would be)
Nov 9 '06 #22
Jordan Abel wrote:
CBFalconer wrote:
.... snip ...
>>
I use the text version all the time. It is quickly and easily
searched and/or grepped. I modified the published version slightly
(reducing the lh margin, and stripping the page breaks) so it is
easily used for usenet quotes, etc. The result is bz2d, and
available on:

<http://cbfalconer.home.att.net/download/>

The results of a text dump from N1124 are virtually useless. So I
put up with the differences.

Has anyone tried making a "polished" text version of N1124? Would
such a thing be compatible with WG14's copyrights (though it seems
to me that if your modifications to n869 are ok, this would be)
I have no reason to assume that it is ok, I only know that I have
received no requests to withdraw it.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Nov 9 '06 #23
On 7 Nov 2006 23:03:53 GMT, in comp.lang.c , "Default User"
<de***********@yahoo.comwrote:
>Mark McIntyre wrote:

>So what? Cola and cake part of the life of C programmers. Are either
of those topical here?


I didn't know there was going to be cake today. What kind?
Oat.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Nov 9 '06 #24
Mark McIntyre <ma**********@spamcop.netwrote:
On 7 Nov 2006 23:03:53 GMT, in comp.lang.c , "Default User"
Mark McIntyre wrote:
So what? Cola and cake part of the life of C programmers. Are either
of those topical here?
I didn't know there was going to be cake today. What kind?

Oat.
Once the Scotsman, always the Scotsman, right Mark?

I wanted Cherry Cake. At least it _starts_ with a C.

Richard
Nov 10 '06 #25

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

Similar topics

9
by: the_grove_man | last post by:
I guess my question can go in two directions. I create applications that run multiple queries against a database. Generally speaking in the past I have used a Data Control (calling it dat1)...
54
by: bnp | last post by:
Hi, I took a test on C. there was an objective question for program output type. following is the program: main() { char ch; int i =2;
9
by: Steve Peterson | last post by:
Hi I have an .aspx web form in which I would like to output only XML, no HTML. The datasource is a datatable that's bult on the fly based on user input from previous .aspx page so the XML output...
37
by: nobody | last post by:
I am writing a framework that other developers will write plug-ins for. I would like for one of the features of the framework to be to intercept all text written to stdout/stderr and prepend...
1
by: Ben Fidge | last post by:
I've got a User Control that renders site navigation from a database. For some reason, when using Output Caching, none of my LinkButtons fire their PostBack events. The declaration in the...
4
by: RobKinney1 | last post by:
Hello, For security reasons, we need to start overhauling our old C++ applications to run as services instead of applications running on the admin account. I am re-writing these programs using...
6
by: drhilbert | last post by:
Dear all, in these days, we have found a problem we can't solve even after long long googling, so we are here asking your precious help. In our program instead of using cout to print messages...
1
by: Jesse Aldridge | last post by:
I want to put all the output from all of my python programs in one place. I've been trying to get this working for the last few days, but there are lots of annoying little details that are making...
109
by: bonneylake | last post by:
Hey Everyone, Well i am having a problem outputting for my report and hoping someone can explain what i am doing wrong. What the report is about is comparing my company's part price's to d and...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.