a console application in C++

Discussion in 'C++' started by arnuld, Jul 16, 2007.

  1. arnuld

    arnuld Guest

    i want to create a console application in C++ . what can be the 1st
    step ?

    NOTE: i did use Google but that gives me some VC++ based links using
    non-standard libraries.
     
    arnuld, Jul 16, 2007
    #1
    1. Advertising

  2. arnuld

    Jim Langston Guest

    "arnuld" <> wrote in message
    news:...
    >i want to create a console application in C++ . what can be the 1st
    > step ?
    >
    > NOTE: i did use Google but that gives me some VC++ based links using
    > non-standard libraries.


    Download a compiler.
     
    Jim Langston, Jul 16, 2007
    #2
    1. Advertising

  3. arnuld

    arnuld Guest

    > On Jul 16, 1:34 pm, "Jim Langston" <> wrote:
    > "arnuld" <> wrote in message


    > >i want to create a console application in C++ . what can be the 1st
    > > step ?


    > > NOTE: i did use Google but that gives me some VC++ based links using
    > > non-standard libraries.


    > Download a compiler.



    seems like you did like my question. may be it is OT but i wanted to
    write a console application in C++ without using any non-standard
    libraries. i already have the compiler as i have Arch GNU/Linux: GCC
    4.2.1
     
    arnuld, Jul 16, 2007
    #3
  4. arnuld

    arnuld Guest

    > On Jul 16, 2:07 pm, arnuld <> wrote:

    > seems like you did like my question. may be it is OT but i wanted to
    > write a console application in C++ without using any non-standard
    > libraries. i already have the compiler as i have Arch GNU/Linux: GCC
    > 4.2.1


    i meant: "seems like you did NOT like my question. may be it is OT
    but i am not sure it is OT."
     
    arnuld, Jul 16, 2007
    #4
  5. On 2007-07-16 10:03, arnuld wrote:
    > i want to create a console application in C++ . what can be the 1st
    > step ?
    >
    > NOTE: i did use Google but that gives me some VC++ based links using
    > non-standard libraries.


    What do you mean by console application? Roughly speaking there are two
    kinds of applications, console and GUI and I don't think you've written
    any GUI applications yet, which means that what you've done so far are
    console applications.

    If the input/output capabilities of cin/cout are not enough for your
    needs you'll have to use some other, platform specific libraries since
    there's nothing more advanced in standard C++. If this is what you want
    ncurses might be worth looking into.

    --
    Erik Wikström
     
    =?ISO-8859-1?Q?Erik_Wikstr=F6m?=, Jul 16, 2007
    #5
  6. arnuld

    Lionel B Guest

    On Mon, 16 Jul 2007 09:07:59 +0000, arnuld wrote:

    >> On Jul 16, 1:34 pm, "Jim Langston" <> wrote:
    >> "arnuld" <> wrote in message

    >
    >> >i want to create a console application in C++ . what can be the 1st
    >> > step ?

    >
    >> > NOTE: i did use Google but that gives me some VC++ based links using
    >> > non-standard libraries.

    >
    >> Download a compiler.

    >
    >
    > seems like you did like my question. may be it is OT but i wanted to
    > write a console application in C++ without using any non-standard
    > libraries. i already have the compiler as i have Arch GNU/Linux: GCC
    > 4.2.1


    What is your definition of "console application"? Is this a "console
    application"? In a shell, do:

    $ cat > hello.cpp
    #include <iostream>

    int main()
    {
    std::cout << "Hello world" << std::endl;
    }

    $ g++ -std=c++98 -pedantic hello.cpp -o hello
    $ ./hello
    Hello world

    Note: the "-std=c++98 -pedantic" flags ensure that you are compiling
    according to the current C++ standard without any GCC-specific extensions/
    restrictions to the language.

    --
    Lionel B
     
    Lionel B, Jul 16, 2007
    #6
  7. arnuld

    arnuld Guest

    On Jul 16, 2:40 pm, Erik Wikström <> wrote:
    > On 2007-07-16 10:03, arnuld wrote:
    >
    > > i want to create a console application in C++ . what can be the 1st
    > > step ?

    >
    > > NOTE: i did use Google but that gives me some VC++ based links using
    > > non-standard libraries.

    >
    > What do you mean by console application? Roughly speaking there are two
    > kinds of applications, console and GUI and I don't think you've written
    > any GUI applications yet, which means that what you've done so far are
    > console applications.
    >
    > If the input/output capabilities of cin/cout are not enough for your
    > needs you'll have to use some other, platform specific libraries since
    > there's nothing more advanced in standard C++. If this is what you want
    > ncurses might be worth looking into.


    sorry , i was at fault of not being clear. actually what we see at our
    colleges/universities is theoretical foundation like make a programme
    do this and do that. an average student from an average university
    (unlike MIT, CMU etc) reads books and does the things and when he
    enters in to the real-life software work like doing a job in industry
    or working directly with customers, he gets shock at first because it
    is *different*. same happened with me.

    i want to create some console programme, i mean, anything that can be
    called practical work and but which is general and approachable enough
    for a fresher like me..

    any ideas on that ?
     
    arnuld, Jul 16, 2007
    #7
  8. arnuld

    arnuld Guest

    > On Jul 16, 2:50 pm, Lionel B <> wrote:

    > $ g++ -std=c++98 -pedantic hello.cpp -o hello
    > $ ./hello
    > Hello world
    >
    > Note: the "-std=c++98 -pedantic" flags ensure that you are compiling
    > according to the current C++ standard without any GCC-specific extensions/
    > restrictions to the language.



    Lionel, i use this.

    g++ -ansi -pedantic -Wall -Wextra file.cpp

    tell me if it is ok ?
     
    arnuld, Jul 16, 2007
    #8
  9. arnuld

    asterisc Guest

    On Jul 16, 2:20 pm, arnuld <> wrote:
    > > On Jul 16, 2:50 pm, Lionel B <> wrote:
    > > $ g++ -std=c++98 -pedantic hello.cpp -o hello
    > > $ ./hello
    > > Hello world

    >
    > > Note: the "-std=c++98 -pedantic" flags ensure that you are compiling
    > > according to the current C++ standard without any GCC-specific extensions/
    > > restrictions to the language.

    >
    > Lionel, i use this.
    >
    > g++ -ansi -pedantic -Wall -Wextra file.cpp
    >
    > tell me if it is ok ?


    if you get the binary than is ok. On the other hand, if you are using
    *nix based OS, man gcc or man g++ may help.
     
    asterisc, Jul 16, 2007
    #9
  10. arnuld

    Lionel B Guest

    On Mon, 16 Jul 2007 11:20:30 +0000, arnuld wrote:

    >> On Jul 16, 2:50 pm, Lionel B <> wrote:

    >
    >> $ g++ -std=c++98 -pedantic hello.cpp -o hello $ ./hello
    >> Hello world
    >>
    >> Note: the "-std=c++98 -pedantic" flags ensure that you are compiling
    >> according to the current C++ standard without any GCC-specific
    >> extensions/ restrictions to the language.

    >
    >
    > Lionel, i use this.
    >
    > g++ -ansi -pedantic -Wall -Wextra file.cpp
    >
    > tell me if it is ok ?


    I used to use -ansi rather than -std=c++98 until it was pointed out to me
    (on this ng) that -std=c++98 is probably more appropriate; ISO is an
    international standardisation organisation, while ANSI is US only.

    Apart from which I've actually just had a look at the GCC manual and it
    doesn't say what -ansi does (if anything) for C++ - it only specifies the
    ISO 1990 C standard, apparently...

    --
    Lionel B
     
    Lionel B, Jul 16, 2007
    #10
  11. arnuld

    Puppet_Sock Guest

    On Jul 16, 4:03 am, arnuld <> wrote:
    > i want to create a console application in C++ . what can be the 1st
    > step ?


    You need a compiler, linker, and the standard libraries.

    You need some kind of ability to produce a source file.
    That can be any convenient text editor that lets you
    make a text file that your compiler can accept.

    But this is off topic here. You need specifics on
    how to run your local program, platform, compiler, etc.
    If you have *language* questions, ask away. But how to
    get your compiler etc. to produce an executable is off
    topic here.

    Look for help files or other docs with your compiler.
    Look for news groups that have your compiler's name
    in their name. Google for tutorials specific to your
    particular compiler and platform.
    Socks
     
    Puppet_Sock, Jul 16, 2007
    #11
  12. arnuld

    Default User Guest

    Lionel B wrote:


    > I used to use -ansi rather than -std=c++98 until it was pointed out
    > to me (on this ng) that -std=c++98 is probably more appropriate; ISO
    > is an international standardisation organisation, while ANSI is US
    > only.
    >
    > Apart from which I've actually just had a look at the GCC manual and
    > it doesn't say what -ansi does (if anything) for C++ - it only
    > specifies the ISO 1990 C standard, apparently...


    From the Solaris man pages:

    -ansi
    In C mode, support all ISO C90 programs. In C++ mode,
    remove GNU extensions that conflict with ISO C++.



    Brian
     
    Default User, Jul 16, 2007
    #12
  13. arnuld

    Guest

    On Jul 16, 7:19 am, arnuld <> wrote:
    > On Jul 16, 2:40 pm, Erik Wikström <> wrote:
    >
    >
    >
    > > On 2007-07-16 10:03, arnuld wrote:

    >
    > > > i want to create a console application in C++ . what can be the 1st
    > > > step ?

    >
    > > > NOTE: i did use Google but that gives me some VC++ based links using
    > > > non-standard libraries.

    >
    > > What do you mean by console application? Roughly speaking there are two
    > > kinds of applications, console and GUI and I don't think you've written
    > > any GUI applications yet, which means that what you've done so far are
    > > console applications.

    >
    > > If the input/output capabilities of cin/cout are not enough for your
    > > needs you'll have to use some other, platform specific libraries since
    > > there's nothing more advanced in standard C++. If this is what you want
    > > ncurses might be worth looking into.

    >
    > sorry , i was at fault of not being clear. actually what we see at our
    > colleges/universities is theoretical foundation like make a programme
    > do this and do that. an average student from an average university
    > (unlike MIT, CMU etc) reads books and does the things and when he
    > enters in to the real-life software work like doing a job in industry
    > or working directly with customers, he gets shock at first because it
    > is *different*. same happened with me.
    >


    What the hell are you on about? This comes off like the rantings of a
    madman

    > i want to create some console programme, i mean, anything that can be
    > called practical work and but which is general and approachable enough
    > for a fresher like me..
    >
    > any ideas on that ?


    Sure. The first is that you aren't going to get anywhere writing
    vague and incomprehensible questions in a newsgroup. If you want to
    write a program then write one. Do the exercises in a textbook.
    Solve a problem. Or, if you're beyond more trivial matters and yearn
    for something more like real-world experience, find an open source
    project. There are plenty of places where open source apps can be
    found. Start with a smaller one, and get familiar with the code --
    add a feature, fix a bug, whatever.
     
    , Jul 16, 2007
    #13
  14. arnuld

    arnuld Guest

    On Jul 16, 11:05 pm, wrote:
    > On Jul 16, 7:19 am, arnuld <> wrote:
    >
    >
    >
    > > On Jul 16, 2:40 pm, Erik Wikström <> wrote:

    >
    > > > On 2007-07-16 10:03, arnuld wrote:

    >
    > > > > i want to create a console application in C++ . what can be the 1st
    > > > > step ?

    >
    > > > > NOTE: i did use Google but that gives me some VC++ based links using
    > > > > non-standard libraries.

    >
    > > > What do you mean by console application? Roughly speaking there are two
    > > > kinds of applications, console and GUI and I don't think you've written
    > > > any GUI applications yet, which means that what you've done so far are
    > > > console applications.

    >
    > > > If the input/output capabilities of cin/cout are not enough for your
    > > > needs you'll have to use some other, platform specific libraries since
    > > > there's nothing more advanced in standard C++. If this is what you want
    > > > ncurses might be worth looking into.

    >
    > > sorry , i was at fault of not being clear. actually what we see at our
    > > colleges/universities is theoretical foundation like make a programme
    > > do this and do that. an average student from an average university
    > > (unlike MIT, CMU etc) reads books and does the things and when he
    > > enters in to the real-life software work like doing a job in industry
    > > or working directly with customers, he gets shock at first because it
    > > is *different*. same happened with me.

    >
    > What the hell are you on about? This comes off like the rantings of a
    > madman
    >
    > > i want to create some console programme, i mean, anything that can be
    > > called practical work and but which is general and approachable enough
    > > for a fresher like me..

    >
    > > any ideas on that ?

    >
    > Sure. The first is that you aren't going to get anywhere writing
    > vague and incomprehensible questions in a newsgroup. If you want to
    > write a program then write one. Do the exercises in a textbook.
    > Solve a problem. Or, if you're beyond more trivial matters and yearn
    > for something more like real-world experience, find an open source
    > project. There are plenty of places where open source apps can be
    > found. Start with a smaller one, and get familiar with the code --
    > add a feature, fix a bug, whatever.


    TROLL alert....

    *PLONK*
     
    arnuld, Jul 16, 2007
    #14
  15. arnuld

    Kai-Uwe Bux Guest

    arnuld wrote:

    > i want to create a console application in C++ . what can be the 1st
    > step ?


    Find a problem that your program should solve. Without a problem, it is hard
    to tell whether the program is correct/useful.

    > NOTE: i did use Google but that gives me some VC++ based links using
    > non-standard libraries.


    Which libraries you will need is something to be determined once you know
    what you want the program to do.


    Best

    Kai-Uwe Bux
     
    Kai-Uwe Bux, Jul 16, 2007
    #15
  16. arnuld

    Lionel B Guest

    On Mon, 16 Jul 2007 17:41:01 +0000, Default User wrote:

    > Lionel B wrote:
    >
    >
    >> I used to use -ansi rather than -std=c++98 until it was pointed out to
    >> me (on this ng) that -std=c++98 is probably more appropriate; ISO is an
    >> international standardisation organisation, while ANSI is US only.
    >>
    >> Apart from which I've actually just had a look at the GCC manual and it
    >> doesn't say what -ansi does (if anything) for C++ - it only specifies
    >> the ISO 1990 C standard, apparently...

    >
    > From the Solaris man pages:
    >
    > -ansi
    > In C mode, support all ISO C90 programs. In C++ mode, remove
    > GNU extensions that conflict with ISO C++.


    Right, just found that. So it seems that for C++ -ansi *is* actually
    equivalent to -std=c++98. Well... according to the docs, the g++ default
    is -std=gnu++98' which is "the same as -std=c++98 plus GNU extensions".
    So I guess if you remove those extensions you're left with -std=c++98. Or
    am I missing some subtlety here?

    Upshot is I think I'll stick with the more straightforward "specify the
    actual standard you want" approach; i.e. -std=c++98

    Oh, and I'm told you need -pedantic too for strict standards-
    compliance... now *that* has without doubt the most confusing man entry I
    have ever seen. Ever.

    --
    Lionel B
     
    Lionel B, Jul 16, 2007
    #16
  17. arnuld

    BobR Guest

    arnuld <> wrote in message...
    On Jul 16, 11:05 pm, wrote:
    /* """
    > > i want to create some console programme, i mean, anything that can be
    > > called practical work and but which is general and approachable enough
    > > for a fresher like me..
    > > any ideas on that ?

    >
    > Sure. The first is that you aren't going to get anywhere writing
    > vague and incomprehensible questions in a newsgroup. If you want to
    > write a program then write one. Do the exercises in a textbook.
    > Solve a problem. Or, if you're beyond more trivial matters and yearn
    > for something more like real-world experience, find an open source
    > project. There are plenty of places where open source apps can be
    > found. Start with a smaller one, and get familiar with the code --
    > add a feature, fix a bug, whatever.


    TROLL alert....

    *PLONK*
    """ */

    Troll?!?!? Look who's calling the kettle black!!

    (hint: You've been given simple example(s), but, you keep asking the same
    question. That's what 'Trolls' do!)

    Show what *you* have done, and explain what problem you have with it.

    Whether it's a 'console' or 'GUI' is the compilers function, not 'C++'.
    I put 'console apps' in a 'class', and instantiate(run) them in wxWidgets (a
    GUI), to try/test them. That has nothing to do with 'C++' (though it's coded
    in 'C++'. <G>).

    --
    Bob R
    POVrookie
     
    BobR, Jul 17, 2007
    #17
  18. arnuld

    arnuld Guest

    > On Jul 17, 4:25 am, "BobR" <> wrote:
    > arnuld <> wrote in message...


    > TROLL alert....
    >
    > *PLONK*
    > """ */
    >
    > Troll?!?!? Look who's calling the kettle black!!


    BobR, a little search will tell you why i called "" a
    troll. i am posting here from some time. did i call anyone a troll
    till yet, except ""


    ???

    > (hint: You've been given simple example(s), but, you keep asking the same
    > question. That's what 'Trolls' do!)


    ok , then call me a troll and *PLONK* me if you love to do so.

    > Show what *you* have done, and explain what problem you have with it.
    >
    > Whether it's a 'console' or 'GUI' is the compilers function, not 'C++'.
    > I put 'console apps' in a 'class', and instantiate(run) them in wxWidgets (a
    > GUI), to try/test them. That has nothing to do with 'C++' (though it's coded
    > in 'C++'. <G>).


    well, thanks but i will not try GUIs, ATM, i will focus on creating
    classes.
     
    arnuld, Jul 17, 2007
    #18
  19. arnuld

    James Kanze Guest

    On Jul 16, 11:50 am, Lionel B <> wrote:
    > On Mon, 16 Jul 2007 09:07:59 +0000, arnuld wrote:


    [...]
    > Note: the "-std=c++98 -pedantic" flags ensure that you are compiling
    > according to the current C++ standard without any GCC-specific extensions/
    > restrictions to the language.


    Note that the "-std=c++98 -pedantic" flags only affect the
    compiler, and do *not* ensure that you are not including
    non-standard headers or linking against non-standard libraries.
    Something like:

    #include <unistd.h>

    int
    main()
    {
    static char const h[] = "Hello, world!\n" ;
    read( 1, h, sizeof(h)-1 ) ;
    return 0 ;
    }

    will compile and link, with those flags, on my system, but is
    anything but standard C++. (It is standard Posix, however:).)
    On most (all?) Unix platforms, the C standard library and the
    Posix standard library are merged in a way that makes it
    impossible to separate them. (I'm not aware of an option for
    VC++ which would make #include <windows.h> illegal either.)

    With regards to the original question, concerning writing an
    application in "standard" C++, the only real answer it to start
    by documenting what is standard C++, and what isn't, and then
    use a lot of personal discipline. Having two systems at your
    disposition, one Windows and one Unix, and ensuring that all of
    the code compiles and runs on both, helps a lot too. (But note
    that both systems tend to have features to help migration from
    the other, so it's not really a guarantee either.)

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Jul 17, 2007
    #19
  20. arnuld

    James Kanze Guest

    On Jul 16, 1:20 pm, arnuld <> wrote:
    > > On Jul 16, 2:50 pm, Lionel B <> wrote:
    > > $ g++ -std=c++98 -pedantic hello.cpp -o hello
    > > $ ./hello
    > > Hello world


    > > Note: the "-std=c++98 -pedantic" flags ensure that you are compiling
    > > according to the current C++ standard without any GCC-specific extensions/
    > > restrictions to the language.


    > Lionel, i use this.


    > g++ -ansi -pedantic -Wall -Wextra file.cpp


    > tell me if it is ok ?


    You probably want to add "-D_GLIBCXX_CONCEPT_CHECKS
    -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC", to catch illegal
    use of the library.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Jul 17, 2007
    #20
    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. Ben Finney
    Replies:
    2
    Views:
    1,017
    Egor Bolonev
    Jun 30, 2003
  2. Egor Bolonev
    Replies:
    0
    Views:
    493
    Egor Bolonev
    Jun 30, 2003
  3. Serge Terekhoff
    Replies:
    0
    Views:
    656
    Serge Terekhoff
    Jun 30, 2003
  4. Miktor
    Replies:
    7
    Views:
    12,157
    Joe Bacigalupa
    Aug 9, 2005
  5. Replies:
    5
    Views:
    3,458
    James Kanze
    Mar 4, 2008
Loading...

Share This Page