My first program (and a few questions)

This is a discussion on My first program (and a few questions) within the C++ Programming forums, part of the General Programming Boards category; I just made my first C++ program... It is very simple but i wanted to show it anyway. Its a ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    100

    Talking My first program (and a few questions)

    I just made my first C++ program... It is very simple but i wanted to show it anyway.
    Its a simple calculator i made.

    But i have a few questions too.

    Can you draw in a console window... like draw a blue rectangle?
    And can you use fonts in a consol window? and colored text?

    thanks
    Attached Files Attached Files

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Rectangles etc., yes, the only way I know of is using mode 13h, though.

    Fonts, no, not to my knowledge.

    Colored text, yep. Go here for some examples, etc.

    Good job on your first program. A few things though: there's no main program loop so it returns after giving the user the chance to execute one function.

    Your code is really good though. I don't see any of the normal "first program bad habits" (void main(), etc.). Good job.
    Last edited by jdinger; 05-27-2002 at 11:35 PM.

  3. #3
    Registered User Invincible's Avatar
    Join Date
    Feb 2002
    Posts
    210
    Very nice beginner program, shows a lot more promise than "Hello World!"

    If you want cheesy graphics in the windows console look up console functions at MSDN. I believe they're declared in wincon.h...

    The wincon.h functions are just a handful of functions that give you more control over console output such as color, ascii chars (system dependent), and input devices. Overall, doing anything other than plain text in the conosle is limited. The user gets ultimate control over window size, and there's no way to set font sizes or styles (at least no documented way) I've wasted plenty of time in this area... but hey if you're after simplicity this will do.

    You could do DOS graphics via mode 13h (VGA Graphics), but that's not really console and requires knowledge of assembly language. Same for modeX (XVGA graphics).

    If you want nice graphics or a gui without hassles, learn the Win32 Api, Direct X, or OpenGL.

    Probably more than you wanted to know, but this is the standard Invincible graphics primer

    Good luck!
    "The mind, like a parachute, only functions when open."

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    2
    What's wrong with " void main() " ?

    That's the way we learned at my school from a textbook.

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    15
    void main is a baid habit to learn. and hey i can barely do hello world and its code was given to me :P

    *wishes he could use dumbass variables and option explicit like in vb class...*

    Ok just one question, what do the \n's do?
    Last edited by Dell Boy; 05-28-2002 at 04:40 AM.
    Dude, your getting a dell!

  6. #6
    Nerd Xmevs's Avatar
    Join Date
    Apr 2002
    Posts
    146
    There's a dos-graphics tutorial on www.brackeen.com
    It's in C, but the C++ compiler can also compile C, so it shouldn't be a problem...

  7. #7
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    What's wrong with " void main() " ?
    Because Bjarne said so.

    Ok just one question, what do the \n's do?
    the "\n" are newlines. If you're used to VB then it's the same thing as vbCrLf.

  8. #8
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326
    Code:
        if (whatToDo == 5)
        {
        // exit program
        }
    That should be

    Code:
        if (whatToDo == 5)
        {
        return 0;   // exit program
        }
    This way if whatToDo is 5, you exit the program instead of going through all the other if statements. Maybe a switch statement would make the code look better.

  9. #9
    Unregistered
    Guest
    yea i have a year of vb, thnx for the comparison!

  10. #10
    Registered User
    Join Date
    May 2002
    Posts
    100
    Thanks.....

    Can i make the the consol fullscreen?

  11. #11
    Registered User Invincible's Avatar
    Join Date
    Feb 2002
    Posts
    210
    Can i make the the consol fullscreen?
    There are 2 ways. One is easy and poor practice, the other is difficult and not worth the effort.

    1. Force keyboard input so your app does an alt+enter at startup

    2. Hack the kernel (methods vary from OS to OS)


    BTW, I thought '\n' stood for "newbie"...

    Edit:
    then it's the same thing as vbCrLf.
    I knew there was a reason I stopped using VB...
    Last edited by Invincible; 05-28-2002 at 01:46 PM.
    "The mind, like a parachute, only functions when open."

  12. #12
    Registered User
    Join Date
    May 2002
    Posts
    100
    Originally posted by Invincible

    1. Force keyboard input so your app does an alt+enter at startup
    Ok... but how do i do that?

  13. #13
    Registered User Invincible's Avatar
    Join Date
    Feb 2002
    Posts
    210
    You search the boards (same place I found it) and let poor old Invincible be so he can do his algebra homework and study for his exam which is tomorrow.

    try not ... do
    "The mind, like a parachute, only functions when open."

  14. #14
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    Don't take me wrong elfjuice. Go for it buddy!
    But when given a choice, always try the hardest way first. You'll be amazed at how simple sometimes it ends to be. But even if not,... man! the things you'll learn!
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  15. #15
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    So you're telling him to hack the kernel?

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

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