私はプロジェクトの基本コードを書いています。私は、キーボードエミュレータを使ってRFIDリーダーからの入力を受けようとしているところです。以下はこの時点までの私のコードです:キーボードエミュレータからの文字列入力ヘルプ
#include <iostream>
#include <ios>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
char product; //declaring the variable for the switch/case
int Pay = 0; //Declaring the variable Pay
int Payment = 0;
double Total = 0; // Declaring the Final Total variable
double Subtotal = 0; // Declaring the variable Subtotal
double Tax = 0; // Declaring the variable Tax
int m = 0; //counts the amount of times milk is scanned
int b = 0; //counts the amount of times beer is scanned
int c = 0; //counts the amount of times candy bar is scanned
int r = 0; //counts the amount of times rice is scanned
cout << "Scan the product you desire to purchase: \n";//Asking user to input product purchasing
cout << "When ready to checkout press the z button.\n\n\n"; //Telling user to press button z to pay
while(Pay < 1) //Keeps in the loop until pay is increased to 1
{
getline(cin, product); //Taking input and assining to the variable product
if(product == E007C02A55EF918D)
{
cout << "6 pack of Budlight...........$6.49\n"; // If the button b is pushed displays
Subtotal = Subtotal + Beer; // Calculates the Subtotal and stores it
Tax = Beer * Taxrate + Tax; // Claculates the total Tax and stores it
b++;
}
else if(product == E007C02A55EF937C)
{
cout << "Snickers Bar.................$0.99\n";// If the button c is pusehd displays
Subtotal = Subtotal + Candy_Bar;
Tax = Candy_Bar * Taxrate + Tax;
c++;
}
else if(product == E007C02A554A7A8B)
{
cout << "1 Gallon of 2% Milk..........$3.99\n";//If the button m is pushed displays
Subtotal = Subtotal + Milk;
m++;
}
else if(product == E007C02A55CE0766)
{
cout << "Box of Brown Rice............$2.79\n";//If the button r is pushed displays
Subtotal = Subtotal + Rice;
r++;
}
else
cout << "Invaild product. Please scan a different product.\n";
if (product == 'z')
Pay++; //When finished it increases pay to 1 to break the while loop
Total = Subtotal + Tax; // Claculates the Total
}
私はこのコードをコンパイルするためにMSVS 2010を使用しています。このコードでは、E007C02A55EF918Dが定義されていないと言ってコンパイルできません。 E007C02A55EF918DはRFIDタグのシリアル番号で、入力しようとしているものです。私はgetline関数にも問題があることを知っていますが、シリアル番号を入力として取得することがさらに心配です。
コンパイラはどのタイプが 'E007C02A55EF918D'であるかを知る必要があります。あなたは' char'(製品)をコンパイラにとって未知のものと比較しています。 – Nasreddine