Menu

Trying to learn C Programming with Dev-C++

2009-01-20
2012-09-26
  • Brian Beauchamp

    Brian Beauchamp - 2009-01-20

    Ok,

    where do I begin..

    Im running Vista Ultimate 64bit

    I have C for dummies which I am reading..

    It says to go out and get a compiler which I did..(Dev-C++)

    And a text editor
    I have Notepad2

    So I write out the first example in notepad2

    include <stdio.h>

    int main()
    {
    printf("Goodbye, cruel world!\n") ;
    return(0);
    }

    Then I save it in a specified folder as goodbye.c

    And use Dev-C++ to open goodbye.c
    I compile it.. a little screen blinks at me..

    And I run it and it gives me an error
    "source file not compiled"

    I thought that's what I just did??

    So am I doing something wrong??
    Am I missing a step?

    Maybe Dev-C++ isent the right tool to do what im trying to do??

    Thanks for any help....

     
    • Eric Davis

      Eric Davis - 2009-01-22

      Just as a side note, VC++ is available for free download:

      http://www.microsoft.com/express/download/

      That being said, I still like Dev-C++ and think it's worth using.

       
    • Brian Beauchamp

      Brian Beauchamp - 2009-01-20

      I forgot to mention that my name is Brian and the version of Dev-C++ 4.9.9.2

       
      • Matt Monroe

        Matt Monroe - 2009-01-21

        the screen flicker is the exiting of the Main function of your program. When "0" is "returned in a function of the program, this is considered an exit and the zero usually mean "all is well". When this happens in the main function the entire program exits. Hence the program flicker is actually the opening and then closing of the program. It still writes "Goodbye cruel world", you just can't see it because the program exits quickly. To avoid this, and note: this is not the PROPER or a SECURE way to do this in a real programming environment:

        add this under your first include line

        include <cstdlib>

        and add before "return 0":

        system("Pause");

        This will make the program stay alive at the end of the main function and then display a "Press any key to continue..." prompt in order for it to close. AGAIN ONCE YOU ARE READY, PLEASE FIND THE MORE SECURE WAYS OF CLOSING A CONSOLE APPLICATION ASAP!
        In regards to the compiler error that you mentioned, I will have to step aside for someone else to answer.

         
    • Brian Beauchamp

      Brian Beauchamp - 2009-01-20

      I also wanted to share my compile log..

      Compiler: Default compiler
      Building Makefile: "C:\C scripts\Makefile.win"
      Executing make...
      make.exe -f "C:\C scripts\Makefile.win" all
      gcc.exe Goobye.o -o "Project1.exe" -L"C:/Dev-Cpp/lib"

      /mingw/lib/crt2.o(.text+0x37):crt1.c: undefined reference to `__cpu_features_init'
      collect2: ld returned 1 exit status

      make.exe: *** [Project1.exe] Error 1

      Execution terminated

      Maybe that could shed some light....
      Thanks...

       
    • Wayne Keen

      Wayne Keen - 2009-01-21

      Note that Vista requires some special steps to get Dev to work.

      These steps, and other useful information are covered in the thread titled "Please Read Before Posting a Question"

      Note also that spaces in folder names are a very bad idea.

      Finally, note that Dev-C++ is NOT a compiler. It is an IDE, a fancy editor. It uses a compiler called GCC, that works on windows through another tool called MinGW.

      There is no reason to have Dev-C++ is you are going to use another editor. You might as well just get MinGW and MSYS.

      Wayne

       
    • Eric Davis

      Eric Davis - 2009-01-22

      I went to File/New/Project/Console Application and started from there. Most of the code is produced for you. All you need to do is add stdio.h and the printf() function. It worked as expected.

      /////////////////////////////////////////////////////

      include <cstdlib>

      include <iostream>

      include <stdio.h>

      using namespace std;

      int main(int argc, char *argv[])
      {
      printf("Goodbye, cruel world!\n") ;
      system("PAUSE");
      return EXIT_SUCCESS;
      }

      /////////////////////////////////////////////////////

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.