Hello Everyone I'm learning to code in dev c++ 4.9.8.0 version 2

This is a discussion on Hello Everyone I'm learning to code in dev c++ 4.9.8.0 version 2 within the C++ Programming forums, part of the General Programming Boards category; Hello Everyone I'm learning to code in dev c++ 4.9.8.0 version 2 Here is the code Simple as it is ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    1

    Hello Everyone I'm learning to code in dev c++ 4.9.8.0 version 2

    Hello Everyone I'm learning to code in dev c++ 4.9.8.0 version 2

    Here is the code Simple as it is

    Code:
    #include <stdio.h> 
    main()
    {
    Printf ( " My first program in Dev c++.\n");
    return 0;
    }

    And it doesnt work can anyone help?

    Also I would like to get any helpful links to help a new beginner

    Thankyou Eric

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    25
    Code:
    #include <stdio.h> 
    int main()
    {
    Printf ("My first program in Dev c++.\n");
    return 0;
    }
    u forgot the to add the "int" in front of the main()

  3. #3
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    That's C code, for C++ do this:
    Code:
    #include <iostream>
    using namespace std;
    
    int main(void)
    {
    cout<<"Hello World!"; //C++ for printf()
    
    }
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    4
    youd also want to change "printf" into "cout <<" if ur doing c++

  5. #5
    Registered User
    Join Date
    Jan 2003
    Posts
    25
    ohh no wonder i was like what is this printf i was about to tell him about the cout etc.. but then i didnt know for sure

    Code:
    #include <iostream>
    using namespace std;
    
    int main(void)
    {
    cout<<"Hello World!"; //C++ for printf()
    
    }
    what is that void doing there.. i know voids there because of using namespace std; but why is it there??


    this is what i would use to print out my first program..blah blah is:

    Code:
    #include <iostream.h>
    int main()
    {
    cout << "My first program in Dev c++.\n";
    return 0;
    }

    hope that works
    Last edited by yakabod; 08-22-2003 at 05:48 PM.
    im still a noob...

    ....but im trying my best to help people out

    ...doing that will help me understand more and more about c++


  6. #6
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    void doesn't need to be there at all, I just like to put it there when I'm not using command line arguments (int argc,char* argv[])
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  7. #7
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355
    It was necessary in C though, wasn't it (to put void there)?
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

  8. #8
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    I don't know C...
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  9. #9
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    Originally posted by HybridM
    It was necessary in C though, wasn't it (to put void there)?
    yes.

    In C++ int main() is int main(void)
    In C, int main() is int main(..)

  10. #10
    Registered User
    Join Date
    Jul 2003
    Posts
    10
    In C++ isn't it still correct if you do this:

    Code:
    #include <iostream>
    using namespace std;
    
    main (void)
    {
        cout << "Blah";
    }
    rather than this:

    Code:
    #include <iostream>
    using namespace std;
    
    int main (void)
    {
        cout << "Blah";
        return 0;
    }

  11. #11
    Registered User
    Join Date
    Jan 2003
    Posts
    25
    nahhh

    gotta tell yo prog the function

    gotta be:

    Code:
    #include <iostream>
    using namespace std;
    
    int main (void)
    {
        cout << "Blah";
        return 0;
    }
    im still a noob...

    ....but im trying my best to help people out

    ...doing that will help me understand more and more about c++


  12. #12
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Actually, this should also compile fine as C++, but not C:
    Code:
    int main( void ) {
    }
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  13. #13
    Registered User
    Join Date
    Jul 2003
    Posts
    10
    It compiled fine without the int too, in Dev-C++...

  14. #14
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970

  15. #15
    Registered User
    Join Date
    Jul 2003
    Posts
    8
    It compiles fine because in C++ if you don't specify a data type for a function it defaults to int.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Dev C++ Version 5
    By Zoalord in forum C++ Programming
    Replies: 3
    Last Post: 08-30-2003, 01:56 PM
  3. learning code tags, don't view
    By tagger101 in forum C# Programming
    Replies: 2
    Last Post: 05-21-2003, 03:50 AM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM
  5. Replies: 0
    Last Post: 02-21-2002, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21