1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Serious newbie problem.

Discussion in 'Scripting & Programming' started by Happy protech, Dec 14, 2006.

  1. Happy protech

    Happy protech Bit Poster

    18
    0
    19
    Like some of you guys know, I just started programming with C. I got my compiler yesterday and have been experiancing diffuculties with the first step. :dry

    I posted my question in a programming specific forum. But they don't seem to have a straight answer for my noobie question.

    It's somthing really silly, I just know it.

    I'll repost the one I already made in dev programming just in case the link get removed for advertising, or summut.

    ________________________________________________

    Hi everyone.

    I've literally just started c programming, I got my compiler (Dev-C++) and wrote an example program into it.

    Code:
     #include
    <stdio.h>
    
    int main()
    {
      printf( "I am alive!  Beware.\n" );
      getchar();
      return 0;
    }
    I compile it, that takes .1 of second which I don't know wheter or not is right. I then hit run, and it tells me the "Source file not complied" in an error box.

    The place I got the example program from was cprogramming.com I have a link to the area I was reading, here

    If someone would be so kind to tell me what I'm doing wrong, I'd appriciate it.

    ____________________________________________________

    The links to the other post in dev programming is here. The reason for the link is just to show you guys where I'm at with the problem. And to avoid a repost. If it infringes on advertisment rules then I'm sorry.

    Thanks.
     
  2. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    I have that dev package on my home machine, not the work machine, so for me to help it will have to be much later tonight! :ohmy

    Getting your first program to compile and run is usualy quite a step - so don't be ashamed that you are having trouble!

    When you run the compiler I seem to remember that there is a window at the bottom that gives progress and error messages. What does it say?

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  3. Happy protech

    Happy protech Bit Poster

    18
    0
    19
    Well when I was just opening source files, the compile box would come up and stay up telling me that the file had been compiled succesfully. When I tryed to compile a project, the box would flash at me very quickly, after clicking compile several times I was able to make it that there were errors with the complie.

    The differences were;

    1. When I was just opening a source file, it would compile find n' dandy. When I tryed to run it I would get the error messege, "source file not compiled" even though I'd apparntly had succes with the compile.

    2. When I was opening an project. The compile box would flash at me, and like I said I had to click compile several times to see what had been written in the status area. (errors)

    I was told that opening a source file was wrong, I needed to open a project for my code, it just doesn't compile.

    Maybe when you get home you could paste that code into your compiler and see what happens? It would be appriciated. Or if anyone else has the dev++ compiler, if you could try it in yours, that'd be great.

    -edit*
    I was going to record what I'm doing in fraps, but damn vista seems to be screwing with it, I hear the wispers of "re-format" in the air!
     
  4. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    OK - now I'm at home.

    I cut'n'pasted the code into Dev-C++ after opening a new file (File->New->Source File). (Note that I didn't bother to start a project.)

    Execute->Compile first asks for a filename to save the source in. Entering this and continuing produces errors in the error window at the bottom (I expected this)

    Remove the new line between #include and it's value

    Recompile. A box appears saying "Status done Errors 0 warnings 0)

    You can click in the compile log tab at the bottom to get more info on what was done.

    Execute->Run - Console box pops up as expected and waits for a keypress.

    What does the compile log show when you look at it?

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  5. Happy protech

    Happy protech Bit Poster

    18
    0
    19
    The weird thing is, when I press compile, I get status, done.
    But when I press run, it says source file not compiled, so somthing is lying to me. :p

    I'm not 100% sure what you mean, I tryed bringing
    Code:
    <stdio.h>
    up into the same line as
    Code:
    #include
    , again it compiled, but didn't run.

    When I press compile, I get this,

    [​IMG]

    When I press run, I get this.

    [​IMG]

    Thanks for the time your spending to help me out, Harry. It's really appriciated! I'll get there soon! :biggrin
     
  6. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    OK - I've first checked that I have the same version (I have), and compared things with the screenshots.

    I'm coming to the conclusion that your copy isn't complete in some way.

    Have a look in the bin directory under Dev-Cpp. There should be a lot of .exe files there including cpp.exe, gcc.exe and a number of exes starting mingw32. Are they there?

    EDIT: I'm just off out for dinner - will be back later to continue this.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  7. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    Another thought - try this:

    In the Dev-Cpp directory, which should contain your source files by defaults, at the CMD prompt type:
    Code:
    bin\gcc --version
    On my box I get:
    Code:
    C:\Dev-Cpp>bin\gcc --version
    gcc (GCC) 3.4.2 (mingw-special)
    Copyright (C) 2004 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    If that works try:
    Code:
    bin\gcc hal.1.cpp
    and report what it says.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  8. Happy protech

    Happy protech Bit Poster

    18
    0
    19
    Sorry for the late reply.
    I looked in my bin directory and everythings there, with about 5-6 files starting with mingw32.

    I might be going wrong in the next step. I just opened the cmd prompt up, and typed in bin\gcc --version

    And got the "the system cannot find the path specified".
    Does that mean that I'm missing some files?

    Thanks again Harry, you're very helpfull. :biggrin

     
  9. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    To avoid any doubt - you need to change dir to where the Dev-Cpp is - on my box it was c:\Dev-Cpp as you can see from the cut'n'paste.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  10. Mathematix

    Mathematix Megabyte Poster

    969
    35
    74
    Hi mate

    Here's how your code should look:

    Code:
    #include <stdio.h>
    
    int main()
    {
         puts("I am alive!  Beware.");
         putchar('\n');
    
         return 0;
    }
    
    I find it hard to believe that there is anything wrong with the setup of your compiler, but then again I use Visual Studio over DevC.

    I would suggest that you have told your compiler the type of project/application that you intend to create - for example, where you careful to specify a console application rather than a Windows one? This should be a console application.
     
    Certifications: BSc(Hons) Comp Sci, BCS Award of Merit
    WIP: Not doing certs. Computer geek.

Share This Page

Loading...