Results 1 to 6 of 6

Thread: (solved) C++, dos?

  1. #1

    Thread Starter
    Fanatic Member Kings's Avatar
    Join Date
    Aug 2001
    Posts
    673

    Question (solved) C++, dos?

    Hey

    I just started programming c++ and I have a very stupid question (I think)

    All my programs are dos, is this suppose to be in dos?

    I have this code and it opens a dos window,
    Code:
    #include <iostream.h>
    
    void odd (int a);
    void even (int a);
    
    int main ()
    {
      int i;
      do {
        cout << "Type a number: (0 to exit)";
        cin >> i;
        odd (i);
      } while (i!=0);
      return 0;
    }
    
    void odd (int a)
    {
      if ((a%2)!=0) cout << "Number is odd.\n";
      else even (a);
    }
    
    void even (int a)
    {
      if ((a%2)==0) cout << "Number is even.\n";
      else odd (a);
    }
    Any Idea? Thanks
    Last edited by Kings; Dec 1st, 2001 at 04:29 PM.
    K i n g s

  2. #2
    Addicted Member
    Join Date
    Aug 2001
    Location
    I'm mobile
    Posts
    166
    It's suppose to be dos unless you create specific win32 api programs or mfc programs. When you choose to create a program in msvc++ for example you chose win32 console program right? And when you write the program it's a dos-prog because you haven't written any code that specifies it to create a window or something else.

    If you want windows programs you have to write code that creates windows for you or use mfc appwizards that does this for you. Have a look at www.winprog.org

    good luck!
    [p r a e t o r i a n]

  3. #3

    Thread Starter
    Fanatic Member Kings's Avatar
    Join Date
    Aug 2001
    Posts
    673
    ok thanks. I'll go to that link of you
    K i n g s

  4. #4
    Addicted Member
    Join Date
    Aug 2001
    Location
    I'm mobile
    Posts
    166
    It's a good website, so check it out! Look at the resources too!
    [p r a e t o r i a n]

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Note this:

    Win32 Console Applications are just that - Win32 consoles.

    They are not DOS. They're fully 32-bit, and can access all the Windows features (for example, MessageBox).

    This is useful for debugging because you can still create windows from them, but you can output loads of stuff to the console as well:
    Code:
    HWND hWnd = CreateWindow(...);
    
    if(!hWnd) {
        cout << "Window creation failed" << endl;
        return -1;
    } else {
        cout << "Window handle: " << (LONG_PTR)hWnd << endl;
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    New Member
    Join Date
    Jul 2002
    Posts
    1
    Thanks Kings, for giving me this URL!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width