2017-07-26 4 views
0

C++で自分自身を再学習する簡単なプログラムを作成していますが、大文字小文字の "A":break;}行。誰もが、私はこのエラーを取得し、それを修正する方法を、非常に高く評価されるだろう、なぜ私が理解するのに役立つことができれば'const char [2]'型の値が暗黙的に 'int'に変換されないエラーC++

[値タイプの「のconst charが[2]」 'int型に暗黙的に変換できません]。ありがとうございました!エラーの

画像:http://imgur.com/a/d2A0P

#include <iostream> 
#include <vector> 
#include <string> 
#include <fstream> 
#include <cstdlib> 

using namespace std; 

char printMenuChoice(char choice); 

void printSpace(){ 
    cout << endl; 
} 

int main(){ 
    //Print Menu Choice 
    char choice; 
    choice = printMenuChoice(choice); 
    cout << "Choice is " << choice << endl; 
    switch(choice){ 
     case "A": 

      break; 
    } 
    //Attack 
    //Chop 
    //Shop 
    //Stats 
    //Exit 
} 

char printMenuChoice(char choice){ 
    cout << "[]--- Welcome to Quick Quests ---[]" << endl; 
    printSpace(); 
    cout << "Attack <A>" << endl; 
    cout << "Chop <B>" << endl; 
    cout << "Shop <C>" << endl; 
    cout << "Exit <E>" << endl; 
    printSpace(); 
    cout << "Input Your Choice: "; 

    printSpace(); 
    cin >> choice; 
    choice = toupper(choice); 
    return choice; 
} 

答えて

2

代わりにリテラルcharのリテラルchar*(文字列)を使用しています。代わりにcase 'A':を使用してください。

+0

ありがとうございます!私は側のGML言語で働いていたし、//と/ * * /以外のコメントする別の方法だと思った。 –

関連する問題