Hi guys. This is a program I have to write for a C++ class.
My problem: My teacher says it won't c/l on her computer. She says the #include statements for conio.h and cctype are throwing errors. So my question is this, are cctype and conio.h standard headers?
Any ideas? I can c/l it fine, so I can't really tell you what the error is.
Code:
/*
Module 3 Program - car.cpp
last edit: 1 February 2002, 1411 EST
*/
#include <iostream> //for cin, cout
#include <cctype> //for isalpha(), isspace(), and isdigit()
#include <string> //for atoi()
#include <conio.h> //for clrscr()
#include "apclass/apstring.cpp" //for apstring objects
bool plate_checks_out(char*);
void plate_to_code(char*);
using namespace std;
int main () {
apstring make, model;
char plate[8];
cout << "Enter Make - ";
cin >> make;
cout << "\nEnter Model - ";
cin >> model;
cin.ignore(); //If only cleaning the gutters was this easy
cout << "\nEnter Plate Number - ";
cin.getline(plate, 8);
clrscr();
while (!plate_checks_out(plate)) { //GIGO += a_little_bit
cout << "Hmm, something seems to be wrong with that plate number. "
"\nRemember, the format is: Three letters followed by three numbers. "
"\n\nNow exiting program, have a nice day.";
exit(1);
}
cout << "Make = " << make << '\n';
cout << "Model = " << model << '\n';
cout << plate << " = ";
plate_to_code(plate);
return 0;
}
bool plate_checks_out(char* plate) {
if (isalpha((int) plate[0]) && isalpha((int) plate[1]) &&
isalpha((int) plate[2]) && isspace((int) plate[3]) &&
isdigit((int) plate[4]) && isdigit((int) plate[5]) &&
isdigit((int) plate[6]) ){
return 1;
}
return 0;
}
void plate_to_code(char* plate) {
int numberPart = atoi((const char*)&plate[4]) + toupper((int)plate[0]) + toupper((int)plate[1]) + toupper((int)plate[2]);
cout << char((numberPart % 26) + 65);
cout << numberPart;
return;
}