一千萬個為什麽

搜索

如何從C ++中的字符串中調用特定字符?

我怎麽能回想起第四個字符,並從這個代碼輸出到屏幕上?

#include 
#include 
using namespace std;


int main() {
    cout << "Enter word: ";
    char random[99];
    cin >> random;
    \\right here is where I would like to output the fourth character of the string "random"
    return 0;
}

最佳答案

cout << random[3];

Consider reading a good book on C++

轉載註明原文: 如何從C ++中的字符串中調用特定字符?