Thread: Question

  1. #1
    Registered User Fool's Avatar
    Join Date
    Aug 2001
    Posts
    335

    Question

    I am using the Dev C++ compiler and when I try and use a Window app to write code to it starts me off with a long list of code already. Now my question is where do I start to write my code? I can send the source over email if you'd like to see it.

    -Fool

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    In the WinMain function

    Just a suggestion - since you've never programmed before, don't jump right into Windows programming. Make some DOS apps first to get a feel for it, then move one after you feel comfortable with that.

  3. #3
    Registered User Fool's Avatar
    Join Date
    Aug 2001
    Posts
    335
    At the moment I'm just playing around. I can't think of anything I can do in DOS (really easy!). Any ideas?

    -Fool

  4. #4
    junior member mix0matt's Avatar
    Join Date
    Aug 2001
    Posts
    144

    Windows already?

    What are you trying to compile? The Hello World code?
    I wouldn't mess around with Windows until you have a firm grasp on basic C++. Your school probably won't even let you take a Windows class until your third or fourth year in school...maybe second. Depends on how good you are....

    i don't know anything about Dev-C++, but is there a console app selection? If there is that's what you need to choose. It sounds like you're ended up in a Windows programming wizard. Hence all the code that was added...
    THIS IS NOT JUST A CHRONICLING OF THINGS WE HAVE DONE IN THE PAST BUT OUR RISE TO POWER.

  5. #5
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    but is there a console app selection
    There most certainly is...

    Fool (I always feel like I'm insulting you when I say something), Go here!

    Learn the language, then start doing cool stuff!

  6. #6
    Registered User Fool's Avatar
    Join Date
    Aug 2001
    Posts
    335
    Originally posted by Govtcheez
    Fool (I always feel like I'm insulting you when I say something)
    I don't take it that way. Thanks for the link. I'll mess around some on there. I'm not trying to really do much yet just joke around. I'll wait for class to really learn everything. Thanks for your help though.

    -Fool

  7. #7
    Ecologist
    Join Date
    Aug 2001
    Location
    Utah.
    Posts
    1,291

    Re: Question

    Originally posted by Fool
    I am using the Dev C++ compiler and when I try and use a Window app to write code to it starts me off with a long list of code already. Now my question is where do I start to write my code? I can send the source over email if you'd like to see it.

    -Fool
    Most of that code is used to create a window. A lot of
    code...

    Your code goes in the WinMain function. Here's a simple
    program that doesn't have a created-window. You can see
    how small it is compared to a program that has a window..
    (Eh, am I making sense?)

    Code:
    //Simple message-box program
    
    #include <windows.h>
    #include <windowsx.h>
    
    int WINAPI WinMain(HINSTANCE hinstance,
                       HINSTANCE hprevinstance,
                       LPSTR     lpcmdline,
                       int       ncmdshow)
    
    {
      //Code goes here. Window isn't created for this program.
      //Just a message box. 
    
      MessageBox(NULL, "Hello Fool!", "A message box",MB_OK);
      return 0;
    }


    Anyway, do what Govtcheez said. Start programming console-
    apps first. Most C/C++ books teach that first anyway.

    Goodbye
    Staying away from General.

  8. #8
    Ecologist
    Join Date
    Aug 2001
    Location
    Utah.
    Posts
    1,291
    Woh. 4 posts made while I was typing my reply. Why do I keep
    re-reading what I type? Maybe I have OCD? Eh.
    Staying away from General.

  9. #9
    Registered User Fool's Avatar
    Join Date
    Aug 2001
    Posts
    335
    For some reason I cannot get the Hello World program to work anymore. A DOS window will come up for a second and leave. It will not stay up. Any ideas?

    -Fool

    #include <iostream.h>

    int main()
    {
    cout <<"Hello World!";
    return 0;
    }

  10. #10
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    That was the reason for the getch() at the end. Dev-C++ just runs its course and closes the DOS window unless you tell it to stop.

    Posted by static
    Maybe I have OCD?
    That's probably a good thing, being a programmer

  11. #11
    Registered User Fool's Avatar
    Join Date
    Aug 2001
    Posts
    335
    I got the one from the other post...

    #include <stdio.h>
    #include <conio.h>

    int main(void)
    {
    printf("Hello World!");
    getch();
    return 0;
    }
    but isn't that just C? How would you write it in C++? Would it be...

    #include <iostream.h>

    int main()
    {
    cout << "Hello World!";
    return 0;
    }
    -Fool

  12. #12
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742
    Just a suggestion - since you've never programmed before, don't jump right into Windows programming. Make some DOS apps first to get a feel for it, then move one after you feel comfortable with that.
    Don't you mean Win32 console?
    I compile code with:
    Visual Studio.NET beta2

  13. #13
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    Fool:
    Just because you're writing in C++ doesn't mean you can't include code for C. If you include conio.h, you can still use getch without any problems.

    Dean:
    Of course that's what I meant, but since Fool's just starting, I didn't think it'd be a good idea to argue about what's DOS and what's Win32 console. The common thought of most newbies is that anything that looks like DOS is DOS.

  14. #14
    Registered User Fool's Avatar
    Join Date
    Aug 2001
    Posts
    335
    Originally posted by Govtcheez
    The common thought of most newbies is that anything that looks like DOS is DOS.
    lolololololol

    I'm a n00b!

    -Fool

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM