如何才能将<div class="container">
<div class="main-display">
Main box: this box should be at the center of the container.
</div>
<ul class="extra-info">
<li>These items should naturally follow the main box and not care about vertical centering.</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>
声明正文中的cout
打印出来?原因是当我尝试在while
的行中写下这句话时,它会弄乱我的cout << password;
。
例如,如果我写password
,它会在末尾显示带有数字的句子。
如果有人能给我一些帮助,我将不胜感激。
以下是我的计划:
cout << "this is your new password " << password;
答案 0 :(得分:0)
您可以使用&#34; endl&#34;要在新行中显示您的密码,那么它不会搞砸:
.container {
display: flex; /* Magic begins */
flex-direction: column;
}
.before, .after {
flex: 1; /* If possible, center .main vertically */
min-height: 0; /* Really, don't care about overflow, just center .main vertically */
}
.main {
align-self: center; /* Center .main horizontally */
}
答案 1 :(得分:0)
您无法在cout
循环中获取while
以后打印。如果它在while循环中,它将在每个循环中执行(直到被if左右包围)。
所以你有两个选择:
在您输入while循环之前打印句子:
cout << "Your new password...";
while(password!='\n'){
...
cout << password;
}
将您的“密码”(不是单词而非单个字符)存储在这样的字符串中:
std::string str = "";
while(password!='\n'){
...
str += password;
}
cout << "Your new password..." << str;