Thread: Is there a problem with Dev C++?

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    204
    The C Programming Language 2nd Edition is a great book. Go ahead and continue reading it. Just make sure you explicit declare the main function returning an int and write "return 0;" before its closing }.

    If it is not taking any arguments, declare it as "int main(void)".

    Also, ignore when the authors cast whatever is returned by malloc.

  2. #17
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Quote Originally Posted by SlyMaelstrom
    I don't know about that. At my school, when running on SunOS, g++ is g++ and gcc is gcc. That is to say, g++ will compile as c++ regardless of extension and gcc will compile as c regardless of extension. Compilers just take whatever you give them and see if it all makes sense. If it doesn't it gives you errors... it doesn't care what the extension is.

    The same seems to apply under Windows, as I just tested.
    gcc merely throws input to other programs - the c compiler, c++ compiler, the linker, etc. I can compile C++ programs with either gcc or g++. From the man page on gcc:
    Quote Originally Posted by man
    For any given input file, the file name suffix determines what kind of compilation is done:
    file.c
    C source code which must be preprocessed.
    ...

    file.cc
    file.cp
    file.cxx
    file.cpp
    file.c++
    file.C

    C++ source code which must be preprocessed. Note that in .cxx, the last two letters must both be literally x. Likewise, .C refers to a literal capital C.
    Thus, you should be able to do (I can - Win32/MinGW, gcc 3.4.2):
    Code:
    C:\...\Projects\cboard>cat hello.cpp
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
            cout << "Hello World." << endl;
            return 0;
    }
    
    C:\...\Projects\cboard>gcc -c -o hello.o hello.cpp
    
    C:\...\Projects\cboard>gcc -o hello.exe hello.o -lstdc++
    
    C:\...\Projects\cboard>hello
    Hello World.
    
    C:\...\Projects\cboard>_
    Of course, note the extra -lstdc++ - gcc by default won't link with the standard library - you have to do that yourself. (Of course, you can use C++ without any std stuff as well...) (Throwing the -v (verbose) switch shows that gcc invokes cc1plus.) But generally, I agree - I use gcc for C code, and g++ for C++ code.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #18
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    3) why does it contain perpetual whitespace? (if you hold down rightarrow it will continue to go on into an infinity of white space instead of advancing to the next line)
    3) Er... mine doesn't do that?
    Dev-C++ 4.0 has "perpetual whitespace", although you can figure out where the end of the line actually is by pressing end. Dev-C++ 4.9.* can have both versions, but the default is notepad-style.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #19
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    >>i dunno why u say to post the actual code that i tried??? this is
    >>EXACTLY what the book says and what i tried.

    Clearly the second post of code isn't - I reffer to this line:

    printf("ld\n", nc;)

    This won't compile as the semi-colon is inside the parentheses.

    Check this out for books
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  2. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  3. Problem running prog I wrote in Dev C++
    By KidMan in forum C Programming
    Replies: 8
    Last Post: 09-22-2005, 01:50 AM
  4. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM