Any ideas why this isn't working?
Hi everyone,
I'm trying out an exersize of a book I'm reading.
Have a look at the code:
[I]#include <iostream.h>
#include <conio.h>
class employee
{
private:
char name[20];
int n;
int serial_number;
public:
void input()
{
char ch;
n = 0;
cout<<"Enter Name: ";
do
{
ch = getche();
name[n++] = ch;
}while(ch != '\r');
cout<<"Enter Serial Number: ";
cin>>serial_number;
}
void display()
{
cout<<"Name: ";
for (int i=0;i<n;++i)
cout<<name[i];
cout<<"\nSerial Number: "<<serial_number;
}
void purge()
{
serial_number = 0;
for (int i=0;i<n;++i)
name = ' ';
}
};
void main()
{
employee e1;
e1.input();
e1.display();
e1.purge();
e1.display();
}
I'm using Visual C++ 6 Standard Edition on WIN XP.
The above compiles with no errors & no warnings.
However, when I run the program, nothing comes...
Then, I press ENTER and this comes: "Enter name: Enter serial number: ".
What dya think might be the problem?
Thanks in advance :D
Marc :)