I get the following error when I try to compile this code. Can anyone help me make sense of this error?

I have tried defining keystroke as a string and a char, I get the error either way.

1>------ Build started: Project: Register, Configuration: Debug Win32 ------
1>Compiling...
1>Register.cpp
1>i:\c++\register\register\register.cpp(121) : error C2446: '!=' : no conversion from 'const char *' to 'int'
1> There is no context in which this conversion is possible
1>i:\c++\register\register\register.cpp(121) : error C2040: '!=' : 'int' differs in levels of indirection from 'const char [2]'
1>i:\c++\register\register\register.cpp(126) : error C2440: '=' : cannot convert from 'std::string' to 'char'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>Build log was saved at "file://i:\c++\Register\Register\Debug\BuildLog.htm"
1>Register - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

/* Program Name:Register.cpp

   Description: 

   Name:Scott Streit			Class No.: 4467
   Date:11/14/09			  	VisualC++
*/
//********************************** Includes
#include <cfloat>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cctype>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
#include <ctime>
#include <conio.h>
#include <windows.h>
#include <sstream>

#define cls system("cls")
#define frz system("pause");
#define yl  system("color 0e");

using namespace std;

//********************************** Type definitions
struct cashregister
{
	string key;
	string item;
	double price;
};//end structure

ifstream inputfile ("i:\\c++\\food.txt");
ofstream print ("i:\\c++\\register.txt");
//********************************** Function Prototypes
void initalize(cashregister menu[26], cashregister order[26]);
void checkdatafile();
void getdata(cashregister menu[26]);
void takeorder(cashregister menu[26], cashregister order[26]);
void math();
void displayorder();
void printtofile();
//********************************** Main Function


int main()
{
	time_t t;
	time(&t);
	yl;
	cls;
	cashregister menu[26];
	cashregister order[26];

	//function calls
	initalize(menu, order);
	checkdatafile();
	getdata(menu);
	takeorder(menu, order);
	math();
	displayorder();
	printtofile();


       
	frz;
	return 0;
} // end of main function

//********************************** Function Definitions
void initalize(cashregister menu[26], cashregister order[26])
{
  	int i;
	for(i=0; i<26; i++)
	{
		menu[i].key="";
		menu[i].item="";
		menu[i].price=0.0;
	}
}// end initialize
void checkdatafile()
{
	if(!inputfile)
	{
		cout<<"Error opening data file\n";
		frz;
		exit(1);
	}//end if
}//end checkdatafile
void getdata(cashregister menu[26])
{
	for(int i=0; i<26; i++)
	{
		getline(inputfile, menu[i].key);
		getline(inputfile, menu[i].item);
		inputfile>>menu[i].price;		
		inputfile.ignore(80,'\n');
	} // end for
	inputfile.close();
	
	
	
	//for (int i=0;i<26;i++)
	//{
	//	cout<<menu[i].key<<"\t"<<menu[i].item<<"\t"<<menu[i].price<<"\n";
	//}//end temporary display item
} // getdata
void takeorder(cashregister menu[26], cashregister order[26])
{
	string phrase;
	char keystroke;
	int count=0;
	phrase="Welcome to Streit's Burger Stop";
	cout<<setw((phrase.length()/2)+40)<<phrase<<"\n";
	cout<<"\nPlease begin entering your order.\n";

	while ((keystroke=getch())!="=")
	{
		count++;
		cin>>keystroke;
			for (int i=0;i<26;i++)
				if (keystroke=menu[i].key)
				{
					menu[i].item=order[count].item;
					menu[i].price=order[count].price;
				}//end if
	}//end while

}//end takeorder
void math()
{
	cout<<"at math\n";
}//end math
void displayorder()
{
	cout<<"at displayorder\n";
}//end display order
void printtofile()
{
	cout<<"at printtofile\n";
}//end printtofile

while ((keystroke=getch())!="=")

here "=" and '=' are different.
You should use the '='. because "=" is a string literal ( there is a string pool concept that string literals are normally put in the const pool). So
that is the wrong in that line 121

here "=" and '=' are different.
You should use the '='. because "=" is a string literal ( there is a string pool concept that string literals are normally put in the const pool). So
that is the wrong in that line 121

when I define keystroke as char and use single quotes I get this error.

1>------ Build started: Project: Register, Configuration: Debug Win32 ------
1>Compiling...
1>Register.cpp
1>i:\c++\register\register\register.cpp(121) : warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.
1> c:\program files\microsoft visual studio 9.0\vc\include\conio.h(145) : see declaration of 'getch'
1>i:\c++\register\register\register.cpp(126) : error C2440: '=' : cannot convert from 'std::string' to 'char'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>Build log was saved at "file://i:\c++\Register\Register\Debug\BuildLog.htm"
1>Register - 1 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


However when I define keystroke as string and use double quotes I only get the warning message.

1>i:\c++\register\register\register.cpp(121) : warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.
1> c:\program files\microsoft visual studio 9.0\vc\include\conio.h(145) : see declaration of 'getch'

Any thoughts why that is so?

This article has been dead for over six months. Start a new discussion instead.