To use words for a variable

This is a discussion on To use words for a variable within the C++ Programming forums, part of the General Programming Boards category; Code:
//To use a persons name
#include<iostream.h>
main()
{
int a;
char c,
cout<<"Enter name"<<"\n";
cin>>c>>;
cin.get();
cout<<"age"<<"\n";
cin>>a;
if(a=xyz)
...

std::string (which you would need to use #include <string> to make use of std::string) would be the right type for your variable. Obviously, xyz is not a string [in any sense]. You probably wanted to say

Code:

if (c == "xyz")

.

You should also avoid the old style <iostream.h> in preference of <iostream> - although you may find that the 10+ years old Turbo C is not suitable for modern C++ compiling, so you may need to update to a later compiler - there are free ones around, and suggestions for those if you search the forum - there's usually one or two suggestions of this per week.

Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.