Simple Question

Discussion in 'C Programming' started by Materialised, Oct 14, 2003.

  1. Materialised

    Materialised Guest

    Ok, I need some info on how to print in colours to the xterm using c.

    take a simple program

    #include <stdio.h>
    voice main(void)
    {
    printf("I want this in colour\n";
    return 0;
    }

    How would I go about getting coloured output?

    Thanks
     
    Materialised, Oct 14, 2003
    #1
    1. Advertising

  2. Materialised

    Materialised Guest

    Materialised wrote:
    > Ok, I need some info on how to print in colours to the xterm using c.
    >
    > take a simple program
    >
    > #include <stdio.h>
    > voice main(void)
    > {
    > printf("I want this in colour\n";
    > return 0;
    > }
    >
    > How would I go about getting coloured output?
    >
    > Thanks
    >


    lol oppps teach me to write code drunk no matter how simple

    *void main(void)
     
    Materialised, Oct 14, 2003
    #2
    1. Advertising

  3. Materialised <> spoke thus:

    > Ok, I need some info on how to print in colours to the xterm using c.


    I'll spare all the regulars the hassle (you're welcome, lol) by stating that
    Standard C has nothing to do with colors or xterm. You'll want to post this
    question in a newsgroup dedicated to your platform (comp.unix.programmer comes
    mind). This newsgroup is dedicated to ANSI C, and all other questions are
    off-topic.

    --
    Christopher Benson-Manica | Upon the wheel thy fate doth turn,
    ataru(at)cyberspace.org | upon the rack thy lesson learn.
     
    Christopher Benson-Manica, Oct 14, 2003
    #3
  4. Materialised

    Materialised Guest

    Christopher Benson-Manica wrote:
    > Materialised <> spoke thus:
    >
    >
    >>Ok, I need some info on how to print in colours to the xterm using c.

    >
    >
    > I'll spare all the regulars the hassle (you're welcome, lol) by stating that
    > Standard C has nothing to do with colors or xterm. You'll want to post this
    > question in a newsgroup dedicated to your platform (comp.unix.programmer comes
    > mind). This newsgroup is dedicated to ANSI C, and all other questions are
    > off-topic.
    >

    Thanks sorry for the waste of bandwidth.
     
    Materialised, Oct 14, 2003
    #4
  5. Materialised <> spoke thus:

    > *void main(void)


    void_main_corrections++; /* and you thought INT_MAX was big ;) */

    The only standard prototypes for main() are
    int main( void );
    int main( int argc, char** argv );

    Whatever source you're using that says your prototype is correct is wrong.

    --
    Christopher Benson-Manica | Upon the wheel thy fate doth turn,
    ataru(at)cyberspace.org | upon the rack thy lesson learn.
     
    Christopher Benson-Manica, Oct 14, 2003
    #5
  6. Materialised

    Mark Gordon Guest

    On Tue, 14 Oct 2003 20:59:05 +0100
    Materialised <> wrote:

    > Materialised wrote:
    > > Ok, I need some info on how to print in colours to the xterm using
    > > c.
    > >
    > > take a simple program
    > >
    > > #include <stdio.h>
    > > voice main(void)


    Wrong.

    > > {
    > > printf("I want this in colour\n";
    > > return 0;
    > > }
    > >
    > > How would I go about getting coloured output?


    You can't in standard C. Try in Unix programming news group.

    > lol oppps teach me to write code drunk no matter how simple
    >
    > *void main(void)


    I would say that is more wrong, but you can't get more wrong than
    completely wrong. main returns an int so it is
    int main(void)
    --
    Mark Gordon
    Paid to be a Geek & a Senior Software Developer
    Although my email address says spamtrap, it is real and I read it.
     
    Mark Gordon, Oct 14, 2003
    #6
  7. Materialised

    CBFalconer Guest

    Materialised wrote:
    >
    > Ok, I need some info on how to print in colours to the xterm using c.
    >
    > take a simple program
    >
    > #include <stdio.h>
    > voice main(void)
    > {
    > printf("I want this in colour\n";
    > return 0;
    > }
    >
    > How would I go about getting coloured output?


    Take a sheet of tinted transparent plastic and place it over the
    CRT screen. If you have several sheets of different colors you
    can adjust the color to suit.

    In other words standard C can't do this. It depends on your
    hardware and OS etc.

    --
    Chuck F () ()
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net> USE worldnet address!
     
    CBFalconer, Oct 15, 2003
    #7
  8. Materialised

    Dan Pop Guest

    In <> Mark Gordon <> writes:

    >On Tue, 14 Oct 2003 20:59:05 +0100
    >Materialised <> wrote:
    >
    >> > How would I go about getting coloured output?

    >
    >You can't in standard C. Try in Unix programming news group.


    Bad redirection. The question belongs to comp.terminals, because Unix
    is as colour blind as standard C.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
     
    Dan Pop, Oct 15, 2003
    #8
  9. Materialised

    Fao, Sean Guest

    "Materialised" <> wrote in message
    news:bmhkd2$n5sj1$-berlin.de...
    > printf("I want this in colour\n";


    You might want to also fix this line.
     
    Fao, Sean, Oct 15, 2003
    #9
  10. On Wed, 15 Oct 2003 13:34:50 +0000, Dan Pop wrote:

    > In <> Mark Gordon <> writes:
    >
    >>On Tue, 14 Oct 2003 20:59:05 +0100
    >>Materialised <> wrote:
    >>
    >>> > How would I go about getting coloured output?

    >>
    >>You can't in standard C. Try in Unix programming news group.

    >
    > Bad redirection. The question belongs to comp.terminals, because Unix
    > is as colour blind as standard C.


    Programming directly to the terminal would be silly.

    Since *ix provides libraries to do this a unix programming
    news group is a very appropriate place to ask.
     
    Sheldon Simms, Oct 15, 2003
    #10
  11. Materialised

    Dan Pop Guest

    In <> Sheldon Simms <> writes:

    >On Wed, 15 Oct 2003 13:34:50 +0000, Dan Pop wrote:
    >
    >> In <> Mark Gordon <> writes:
    >>
    >>>On Tue, 14 Oct 2003 20:59:05 +0100
    >>>Materialised <> wrote:
    >>>
    >>>> > How would I go about getting coloured output?
    >>>
    >>>You can't in standard C. Try in Unix programming news group.

    >>
    >> Bad redirection. The question belongs to comp.terminals, because Unix
    >> is as colour blind as standard C.

    >
    >Programming directly to the terminal would be silly.


    It depends on what exactly you want to achieve.

    >Since *ix provides libraries to do this a unix programming
    >news group is a very appropriate place to ask.


    The Unix interface is generic enough not to allow exploiting the full
    capabilities of a given terminal. So, depending on what exactly you want
    to achieve, it may or may not be the right thing.

    When the OP mentions an OS, a redirection to the OS programming related
    newsgroup is the right thing. When the OP mentions a terminal, the
    redirection is to a newsgroup dealing with terminals.

    I might be running this xterm on a Unix box, but the application that
    generates output on it may very well be running on a platform that
    has nothing to do with Unix or its standards.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
     
    Dan Pop, Oct 15, 2003
    #11
  12. On Wed, 15 Oct 2003 17:20:15 +0000, Dan Pop wrote:

    > In <> Sheldon Simms <> writes:
    >
    >>On Wed, 15 Oct 2003 13:34:50 +0000, Dan Pop wrote:
    >>
    >>> In <> Mark Gordon <> writes:
    >>>
    >>>>On Tue, 14 Oct 2003 20:59:05 +0100
    >>>>Materialised <> wrote:
    >>>>
    >>>>> > How would I go about getting coloured output?
    >>>>
    >>>>You can't in standard C. Try in Unix programming news group.
    >>>
    >>> Bad redirection. The question belongs to comp.terminals, because Unix
    >>> is as colour blind as standard C.

    >>
    >>Programming directly to the terminal would be silly.

    >
    > It depends on what exactly you want to achieve.
    >
    >>Since *ix provides libraries to do this a unix programming
    >>news group is a very appropriate place to ask.

    >
    > The Unix interface is generic enough not to allow exploiting the full
    > capabilities of a given terminal. So, depending on what exactly you want
    > to achieve, it may or may not be the right thing.


    The OP wanted to achieve "coloured output". Which is easily
    achievable using curses -- a library which is standardized
    by POSIX and available on every POSIX-conforming system.

    > When the OP mentions an OS, a redirection to the OS programming related
    > newsgroup is the right thing. When the OP mentions a terminal, the
    > redirection is to a newsgroup dealing with terminals.
    >
    > I might be running this xterm on a Unix box, but the application that
    > generates output on it may very well be running on a platform that
    > has nothing to do with Unix or its standards.


    The probability is good that the OP is programming on an Unix/Linux
    platform. The probability is exceedingly great that the OP is programming
    on either some version of Windows or Unix/Linux. In every one of these
    possibilities, the curses library is available.

    The probability is low that the OP wants to learn how to program
    "coloured" output on only one particular type of terminal. The
    probability is exceedingly low that the OP wants to write his/her
    very own terminal-independant "coloured output" library.

    Your argument is pedantry and your answer almost certainly points
    the OP in a direction he does not want to go. I can understand
    being pedantic about what is and is not standard C. I do not
    understand why you feel the need to mislead people who are
    just looking for some help.
     
    Sheldon Simms, Oct 16, 2003
    #12
  13. Materialised

    Dan Pop Guest

    In <> Sheldon Simms <> writes:

    >The OP wanted to achieve "coloured output". Which is easily
    >achievable using curses -- a library which is standardized
    >by POSIX and available on every POSIX-conforming system.


    Without colour support, in the POSIX version. It is the SUS version of
    curses that adds colour support.

    >The probability is low that the OP wants to learn how to program
    >"coloured" output on only one particular type of terminal.


    Then, how do you explain the fact that the OP explicitly mentioned a
    terminal name in his request?

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
     
    Dan Pop, Oct 16, 2003
    #13
  14. [OT] Re: Simple Question

    On Thu, 16 Oct 2003 11:42:17 +0000, Dan Pop wrote:

    > In <> Sheldon Simms <> writes:
    >
    >>The OP wanted to achieve "coloured output". Which is easily
    >>achievable using curses -- a library which is standardized
    >>by POSIX and available on every POSIX-conforming system.

    >
    > Without colour support, in the POSIX version. It is the SUS version of
    > curses that adds colour support.


    Ok. I failed to consider the fact that SUS-Curses is an "extension" and
    was not incorporated into POSIX. It is nonetheless a widely implemented
    standard.

    >>The probability is low that the OP wants to learn how to program
    >>"coloured" output on only one particular type of terminal.

    >
    > Then, how do you explain the fact that the OP explicitly mentioned a
    > terminal name in his request?


    Because he knows that his program will run in an xterm. That doesn't
    mean he would prefer to write his program in an xterm-specific way
    when he can do it easier and more portably by using curses.

    -Sheldon
     
    Sheldon Simms, Oct 17, 2003
    #14
  15. Materialised

    Dan Pop Guest

    Re: [OT] Re: Simple Question

    In <> Sheldon Simms <> writes:

    >On Thu, 16 Oct 2003 11:42:17 +0000, Dan Pop wrote:
    >
    >> In <> Sheldon Simms <> writes:
    >>
    >>>The OP wanted to achieve "coloured output". Which is easily
    >>>achievable using curses -- a library which is standardized
    >>>by POSIX and available on every POSIX-conforming system.

    >>
    >> Without colour support, in the POSIX version. It is the SUS version of
    >> curses that adds colour support.

    >
    >Ok. I failed to consider the fact that SUS-Curses is an "extension" and
    >was not incorporated into POSIX. It is nonetheless a widely implemented
    >standard.


    On Unix systems. Doesn't help much if your application doesn't run on
    one.

    >>>The probability is low that the OP wants to learn how to program
    >>>"coloured" output on only one particular type of terminal.

    >>
    >> Then, how do you explain the fact that the OP explicitly mentioned a
    >> terminal name in his request?

    >
    >Because he knows that his program will run in an xterm. That doesn't
    >mean he would prefer to write his program in an xterm-specific way
    >when he can do it easier and more portably by using curses.


    It's debatable which is more portable, but it's certainly easier NOT to
    use curses for this purpose.

    As for the portability: if you use xterm escape sequences, your code
    will run *everywhere*, but will produce the intended output only when
    its terminal is an xterm (i.e. exactly what the OP was asking for).
    If you use SUS-curses, the program will produce the intended output
    (or an approximation of it, if some capabilities are missing)
    on any terminal but it will be portable *only* to systems with a
    SUS-conforming curses implementation.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
     
    Dan Pop, Oct 17, 2003
    #15
  16. Dan Pop <> wrote:
    > In <> Sheldon Simms <> writes:


    >>The OP wanted to achieve "coloured output". Which is easily
    >>achievable using curses -- a library which is standardized
    >>by POSIX and available on every POSIX-conforming system.


    > Without colour support, in the POSIX version. It is the SUS version of
    > curses that adds colour support.


    hmm - where's a reference to POSIX specifying curses?

    --
    Thomas E. Dickey
    http://invisible-island.net
    ftp://invisible-island.net
     
    Thomas Dickey, Oct 18, 2003
    #16
  17. On Sat, 18 Oct 2003 12:35:01 +0000, Thomas Dickey wrote:

    > Dan Pop <> wrote:
    >> In <> Sheldon Simms <> writes:

    >
    >>>The OP wanted to achieve "coloured output". Which is easily
    >>>achievable using curses -- a library which is standardized
    >>>by POSIX and available on every POSIX-conforming system.

    >
    >> Without colour support, in the POSIX version. It is the SUS version of
    >> curses that adds colour support.

    >
    > hmm - where's a reference to POSIX specifying curses?


    I don't know what Dan was thinking of, but I was thinking
    of curses being part of the Single Unix Specification, which
    was incorporated into POSIX. As Dan pointed out, however,
    Xopen/Curses is not part of base SUS, and wasn't one of the
    things incorporated into POSIX.
     
    Sheldon Simms, Oct 18, 2003
    #17
  18. Sheldon Simms <> wrote:
    > On Sat, 18 Oct 2003 12:35:01 +0000, Thomas Dickey wrote:


    >> Dan Pop <> wrote:
    >>> In <> Sheldon Simms <> writes:

    >>
    >>>>The OP wanted to achieve "coloured output". Which is easily
    >>>>achievable using curses -- a library which is standardized
    >>>>by POSIX and available on every POSIX-conforming system.

    >>
    >>> Without colour support, in the POSIX version. It is the SUS version of
    >>> curses that adds colour support.

    >>
    >> hmm - where's a reference to POSIX specifying curses?


    > I don't know what Dan was thinking of, but I was thinking
    > of curses being part of the Single Unix Specification, which
    > was incorporated into POSIX. As Dan pointed out, however,
    > Xopen/Curses is not part of base SUS, and wasn't one of the
    > things incorporated into POSIX.


    As I read the thread, it states that curses is part of POSIX.
    Not having seen this before, I'm curious if there is a reference to it online.

    --
    Thomas E. Dickey
    http://invisible-island.net
    ftp://invisible-island.net
     
    Thomas Dickey, Oct 20, 2003
    #18
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    584
  2. Kevin Spencer

    Re: Simple Simple question!!!

    Kevin Spencer, Jun 25, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    692
    Kevin Spencer
    Jun 25, 2004
  3. Daniel Frey

    Simple Question - Simple Answer?

    Daniel Frey, Dec 28, 2004, in forum: XML
    Replies:
    4
    Views:
    870
    Daniel Frey
    Jan 12, 2005
  4. Oli

    simple simple question

    Oli, Jan 26, 2004, in forum: ASP General
    Replies:
    10
    Views:
    390
    Roland Hall
    Jan 26, 2004
  5. Peter Bailey

    simple, simple array question

    Peter Bailey, Apr 8, 2008, in forum: Ruby
    Replies:
    7
    Views:
    236
    Peter Bailey
    Apr 8, 2008
Loading...

Share This Page