Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Using Getch()

Reply
Thread Tools

Using Getch()

 
 
Hollow06 Hollow06 is offline
Junior Member
Join Date: Jul 2007
Posts: 2
 
      07-04-2007
I'm learning C++ dummies book to learn C++. I am using bloodshed(latest version as my compiler...although it sux with headers bigtime and never seems to want to work. But I am confortable with it...anyhooo. Here is the dilly-0.

Code:
#include <cstdlib>
#include <iostream>
#include <conio.h>
#include <sstream>
#include <istream>// in stream
#include <iomanip>
#include <stdlib.h> // I've included all these to try and fix wtv the prob.

//This function catches  what numbers are being typed and allows up until the enter key "/r" is pressed.

string EnterOnlyNumbers() {  // A function to make sure only Numbers 
       string numAsString = ""; // are entered.
       char ch = getch();
       while (ch != '/r') {   //warning! -> Multi-character character constant
             if (ch >= '0' && ch <= '9') { /
                    cout << ch;
                    numAsString += ch;
             }
             ch = getch();
       }
       return numAsString;
}
Any ideas or a simpliar way let me know. I'm try to get the basics down so if you want to throw out Your way...that might help. Other wise post back what is wrong. This code is right OUT OF THE BOOK "C++ for Dummies".
 
Reply With Quote
 
 
 
 
Hollow06 Hollow06 is offline
Junior Member
Join Date: Jul 2007
Posts: 2
 
      07-04-2007
wrong slash.....
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a Link Button to redirect to another page by using data from =?Utf-8?B?R1REcml2ZXI=?= ASP .Net 1 02-16-2005 07:04 PM
Error page using the Application_Error void dosnt work when using DIV for a please wait message s_erez@hotmail.com ASP .Net 2 12-24-2004 12:11 PM
no code in webform using vs.net, but in webform using notepad timmso ASP .Net 1 12-12-2003 04:30 PM
Using GetOleDbSchemaTable to get SQL Server Field Description - using pete ASP .Net 1 08-29-2003 10:50 AM
Re: MVP? Index error on nested element using System.xml but NOT using msxml??? William F. Robertson, Jr. ASP .Net 1 06-25-2003 08:08 PM



Advertisments