Couple Quick Questions.

This is a discussion on Couple Quick Questions. within the C++ Programming forums, part of the General Programming Boards category; 1. Can I see an example of a way to get an input character, without hitting enter afterwards. i.e. - ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    15

    Couple Quick Questions.

    1. Can I see an example of a way to get an input character, without hitting enter afterwards.

    i.e. - Hitting A automatically jumps to the switch case for 'A' without hitting enter.

    2. Is there a way to change output colors without:
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE),FOREGROUND_BLUE | FOREGROUND_INTENSITY);

    And can you make your own colors, with hexdecimal or (R,G,B).

    3. Is there a way to flush all the buffers at once? Or just the cout buffer without appending <<flush to the end of a cout statement?

    4. A BASIC Tutorial on Using Classes & Objects, since i'm making and RPG, i have enemies that i need called on, i know Classes are easier then using an if structure and setting the variables for him each time. I just don't know how to create them, aAnd call them. I learn from example, i don't do to well with explanations (does anyone?)


    5. Is there a SIMPLE or Relatively Simple way to call a single bmp or pcx image to the console, i.e. - a single splash screen at the start of the program.

    If you know anything about any of these questions i'd appreciate your answer or suggestion.

    Thanx,
    Darkflame

    P.S. - I gotta thank you guys, i'd never been able to learn what I have without this forum. It's great.

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    1.
    Code:
    #include <conio.h>
    
    int main()
    {
        char in;
        in = getch()
        switch(in) {}// Etc...
        return 0;
    }
    3.
    cout.flush() or cin.flush()

    4. There is one at www.cplusplus.com



    I'm not sure about the other two, but I hope this helps a little.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    1. It's implementation specific but most compilers have something along the lines of getch() in conio.h -

    char a;
    a = getch();

    This will not echo the character on the screen either so if you need displaying you'll have to output it manually.

    2. Depends on your compiler I think (if it's MSVC then no, there is no other way on the console).

    3. cout .flush(); or for input buffer you can use -

    cin.ignore(INT_MAX,'\n');

    if you have input left in the buffer.

    4. Don't know of any, you'd probably be better off with a book. Although if you search google with "C++ class tutorial" you'll probably have a few to choose from.

    5. No, you'll have to use an API to blit it to a window (not a console).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. a couple of questions about System.String
    By Elkvis in forum C# Programming
    Replies: 5
    Last Post: 02-17-2009, 01:48 PM
  2. A couple of Basic questions
    By ozumsafa in forum C Programming
    Replies: 8
    Last Post: 09-26-2007, 04:06 PM
  3. Couple of Questions
    By toonlover in forum Windows Programming
    Replies: 10
    Last Post: 07-14-2006, 01:04 AM
  4. A couple of OOP questions
    By codec in forum C++ Programming
    Replies: 5
    Last Post: 05-03-2004, 07:18 PM
  5. couple questions for newb
    By bluehead in forum C++ Programming
    Replies: 10
    Last Post: 11-24-2001, 02:32 AM

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