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.
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".
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') { [U]//warning! -> Multi-character character constant[/U]
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".