Thread: compiler help

  1. #1
    ___
    Join Date
    Jun 2003
    Posts
    806

    compiler help

    Hi, my name is Justin. I am new here and also to programming. Ok so i was doing my first bit of code which is...


    Code:
    #include <stdio.h>
    
    void main()
    {
       printf(" Hey world");
    }

    Yes, it is simple. The code is not the problem though. Anyhow so I go to compile and run (almost forgot i am using Dev C++ as my compiler). It compiles fine with no errors. But when I click execute it does nothing. I went through the help file but i still could not figure out what i am doing wrong.

    Thanks,


    Justin

  2. #2
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455
    is there an option for build? i know in VS if you do 'build' it will also run it


    zakk wylde == good guitarist, BLS == good band

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    385
    Don't double-click to execute because it's a console app and will probably just flash a screen and go away. Your best bet is to open up a command prompt, cd into the directory where the program is located, and run the program from there. It should run fine from there.

    NOTE: Note sure where you're learning from but you shouldn't be using void main
    Wandering aimlessly through C.....

    http://dbrink.phpwebhosting.com

  4. #4
    ___
    Join Date
    Jun 2003
    Posts
    806
    I am "teaching myself" from a book called ' Beginning C' by Ivor Horton. It is a Wrox book. I hear allot of good things about the book. No there is not a build option either.

    Ok. So to run it from my command prompt i should type this in right.

    Code:
     
    /run C:\Documents and Settings\Justin\Desktop\Compiled files\My first program.exe

    And another thing. the line void main is saying only that the main returns no value. At least its what the book told me in the description of the lines.
    Last edited by ZakkWylde969; 06-07-2003 at 10:18 PM.

  5. #5
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    if the program still doesn't run you could try and add \n at the end if there is somthing poping up after words like a line witch says "dictory/somthing/somthing" then it will overwright what your program wrote I know I hade this problem in the begining (still in the begining though) alothugh I was using a the X term in redhat.

    And you really should use int main ()
    Last edited by Shogun; 06-08-2003 at 12:46 AM.
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  6. #6
    Registered User
    Join Date
    Jun 2003
    Posts
    14
    Justin welcome to the beautifully crypted world of
    C programming.
    ---


    I did not quite get the compiler that you are using,
    however if it is a MSVC++; you should build your
    code <F7>.

    Since you are writting a Console 32 app, you
    should press the '!' icon witihn your IDE.
    -

    I would suggest that you go to the BORLAND website
    and get the free compiler. It doesn't provide an IDE
    however you can compile at the DOS prompt.
    -

    NOTE: If you don't like the DOS prompt you will
    not get to far with C. Start trying to
    write your C code within editor like
    Edit (DOS), Notepad (windows), and
    the such. You should not be heavily
    reliant on an IDE, your compiler should
    do the work for you.
    When you have a good solid foundation
    in structuring your code, strings, pointers,
    structures, functions, and writting your
    own header files ... then you will have a
    better enjoyment of all of the IDE out there
    that offer things like 'view highlighting'
    ---

    I hoped that my advise help you, because we ALL
    have been were you are at.
    ---

    Salem I love your animation on ((void && int) main)
    expression.
    ---

  7. #7
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    > And another thing. the line void main is saying only that the
    > main returns no value.

    A program should always return a value. Therefore main() should be of type int and return a value. This informs the environment of how the program has finished.

  8. #8
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    [QUOTE]Originally posted by CodeMaster
    NOTE: If you don't like the DOS prompt you will not get to far with C.
    [QUOTE]

    Are you saying an IDE is difficult to learn C with because
    1) they are based on C++?
    or
    2) they like to hand-hold you and gives you the parameter lists for functions and keep track of names and such?

    If 2, I can see your point to a small degree. But in the larger picture, I'd rather let the IDE give me the syntax necessary and let me analyze, conceptualize, and basically be creative.

    But, for a beginner, you should have already analyzed, conceptualized, and created your code before you actually sat down to enter it into the computer.

    If 1, I completely disagree. I write C code almost exclusively, and MSC++ works just fine. But I don't think this is what you meant.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  9. #9
    Registered User
    Join Date
    Jun 2003
    Posts
    14
    WaltP,

    In deed this was not what I meant at all.

    Personally I find the help with the parameters lists as you
    stated in your last post most helpful; this feature is called
    INTELLISENSE.

    You see most app that I currently write in C are console
    based, and most people whom I encounter find that
    working at the DOS ... the black screen ... to be very,
    very scary.

    I thank you for your request, WaltP.

    ---

    Justin,

    How's the C programming comming along?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  2. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  3. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 06:42 AM
  4. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 11:28 AM
  5. Bad code or bad compiler?
    By musayume in forum C Programming
    Replies: 3
    Last Post: 10-22-2001, 09:08 PM