The Geek Forum

  • May 14, 2024, 01:22:44 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Due to the prolific nature of these forums, poster aggression is advised.

*

Recent Forum Posts

Shout Box

Members
Stats
  • Total Posts: 129630
  • Total Topics: 7188
  • Online Today: 187
  • Online Ever: 1013
  • (January 12, 2023, 01:18:11 AM)

Author Topic: C++ Help  (Read 2021 times)

HeavyJay

  • Hacker
  • ****
  • Coolio Points: +72/-1
  • Offline Offline
  • Posts: 1500
  • Gorn Tamer
    • View Profile
C++ Help
« on: January 24, 2005, 11:47:27 AM »

I'm finishing up a C++ project due tomorrow (would've been today, but schools was closed due to shitty road conditions.) and I'm stuck at one point.

I need to use a switch statement, but I don't want to use a cin beforehand.  Is there a way to use getch() instead?  I remember being told I could in class, but I can't remember how.
Logged
"Don't just eat that hamburger, eat the HELL out of it!" -- JR "Bob" Dobbs

Cyber_Sniper

  • Jail Bait
  • *
  • Coolio Points: +21/-0
  • Offline Offline
  • Gender: Male
  • Posts: 160
    • View Profile
    • http://msdn.microsoft.com
C++ Help
« Reply #1 on: January 24, 2005, 06:06:07 PM »

Yes...

Hold on give me five minutes to dig the old C++ bible out...

Cyber_Sniper

  • Jail Bait
  • *
  • Coolio Points: +21/-0
  • Offline Offline
  • Gender: Male
  • Posts: 160
    • View Profile
    • http://msdn.microsoft.com
C++ Help
« Reply #2 on: January 24, 2005, 06:21:04 PM »

Something like that might help.

Code: [Select]
#include <conio.h>
#include <iostream>
#include <stdio.h>

void main()
{

   char n;
   printf("Press any key to continue...");
   n = getch();

switch(n)
          {
          case "a":
                  dosomething();
          case "b"
                  dosomething();
          break;
           }
}


My C++ is a little rusty (Well very)..

BizB

  • Forum Moderator
  • Hacker
  • *
  • Coolio Points: +439/-15
  • Offline Offline
  • Gender: Male
  • Posts: 4324
  • Keep making circles
    • View Profile
C++ Help
« Reply #3 on: January 24, 2005, 06:31:37 PM »

I should really dig out the C++ book and dig in.  I haven't written anything in C++ since I discovered PHP.
Logged
Without me, it's just 'aweso'.

HeavyJay

  • Hacker
  • ****
  • Coolio Points: +72/-1
  • Offline Offline
  • Posts: 1500
  • Gorn Tamer
    • View Profile
C++ Help
« Reply #4 on: January 24, 2005, 10:23:48 PM »

I tried what you suggested, CyberSniper, but it didn't work.  *shrugs*

I settled for using a cin instead.  I'm too lazy to go back and fix it now anyways.  Thanks, though.
Logged
"Don't just eat that hamburger, eat the HELL out of it!" -- JR "Bob" Dobbs

TerrorDronze

  • Hacker
  • ****
  • Coolio Points: +22/-10
  • Offline Offline
  • Gender: Male
  • Posts: 1259
  • I'm not narcissistic, I'm just awesome.
    • View Profile
C++ Help
« Reply #5 on: January 25, 2005, 12:06:56 AM »

only C++ programming i've ever done was with Karel.  i taught that robot how to navigate any size maze..... problem is, he took a while to do it.
Logged
Wait, so the might-be-a-bot isn't dead?!