2015-12-15 47 views
-4
// Example program 
#include <iostream> 
#include <string> 

int main() 
{ 
    std::string name; 
    std::cout << "What is your name? "; 
    getline (std::cin, name); 
    std::cout << "Hello. How is your day going " << name << "?\n"; 
    char answer; 
    std::cin >> answer; 
    if (answer == "Mrs. Manuel"|| answer == "Ms. Manuel") 
    std::cout << "You're the person I made this for! YAY YAY YAY YAY"; 

    std::string gender; 
    std::cout << "(!)Disclaimer, may be offensive to some(!) What is your gender?"; 


    std::string ask; 
    std::cout << "Now what is that I can show you? "; 
    getline (std::cin, name); 

} 

这是我的代码,到目前为止,我得到下面的那个时代: 在函数“廉政的main()”: 13:17:警告:比较字符串文字导致未指定的行为[-Waddress] 13:17:错误:ISO C++禁止指针和整数之间的比较[-fpermissive] 13:43:警告:与字符串文字的比较导致未指定的行为[-Waddress] 13:43:错误:ISO C++禁止指针和整数之间的比较[-fpermissive]我不知道如何解决我的错误

请帮我解决这些错误,我不完全确定什么是c ausing他们我已经尝试修复它们,并失败。

+1

第5行主要应该是'字符串应答'而不是'字符串应答' – therainmaker

+1

好对接IntheButtEbolaAods,'char'只能容纳一个字符,但你似乎认为它可以容纳整个字符串'夫人。曼纽尔或女士Manuel'。 – user657267

+0

你有未来的问题:http://stackoverflow.com/questions/21567291/why-does-stdgetline-skip-input-after-a-formatted-extraction – chris

回答

0

答案是char。它应该是字符串。

0

char只接收一个字符,您可能正在使用std::stringchar[]并遍历字符数组。

相关问题