我想知道我缺乏關于陣列輸入的哪些知識。我想輸入一個字符,然后自動轉到下一行代碼。
這是代碼:
char word[21];
for(int i = 0;i < 21; i )
{
word[i] = getch();
//cin>>word[i];
if(word[i] == '/')break;
}
for(int j = 0;j < strlen(word); j )
{
if(j < (strlen(word) - 1 ))cout<<word[j];
}
uj5u.com熱心網友回復:
這是我將如何做到這一點:
char c;
std::cin >> c; // Input the character.
std::cin.ignore(10000, '\n'); // Ignore remaining characters on the line.
您可以將 10000 替換為無符號整數的最大值,但我只是使用了一個不太可能的大數(為不太可能的驅動力提供燃料)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/420587.html
標籤:
