String 'G' is not showing

后端 未结 2 1840
清酒与你
清酒与你 2021-01-27 11:53

So this is the client.cpp file. So what\'s the problem? I declare this string \'G\', I enter the nickname and then here \' cout << G << \":\" << sbuff

相关标签:
2条回答
  • 2021-01-27 12:08

    The string G you declare in the global scope at the top is over shadowed by the string G that you declare in the main scope and thus the one you read into isn't available to the ClientThread method. Delete the declaration in the main scope.

    0 讨论(0)
  • 2021-01-27 12:27

    If that's all the same file, then you're declaring G twice, when you only should do it once.

    // string G;
    cout << "Nickname: " << endl;
    cin >> G;
    
    0 讨论(0)
提交回复
热议问题