虽然我检查了while条件中的EOF,但 while 循环运行了无限次。但它仍然运行了无限次。下面是我的代码:
int code;
cin >> code;
std::ifstream fin;
fin.open("Computers.txt");
std::ofstream temp; // contents of path must be copied to a temp file then renamed back to the path file
temp.open("Computers.txt", ios_base::app);
string line;
string eraseLine = to_string(code);
while ( getline(fin, line) && !fin.eof() ) {
if (line == eraseLine)
{
/*int i = 0;
while (i < 10)
{*/
temp << "";
//i++;
//}
}
if (line != eraseLine) // write all lines to temp other …Run Code Online (Sandbox Code Playgroud) 我只想改变我的身体背景,比如在我点击 时切换btn,我想使用该addEventListener方法。我不确定为什么我的代码不起作用,它仅在 bodybackgroundcolor为紫色时才起作用。
这是我的代码:
var btn = document.querySelector("button");
var body = document.getElementByTagName("body")[0];
btn.addEventListener("click", function() {
if(body.style.backgroundColor = "") {
body.style.backgroundColor = "purple"
} else {
body.style.backgroundColor = ""}
}
);
Run Code Online (Sandbox Code Playgroud) uint16_t a = 0x00 << 8 + 0xB9;
printf("%d",a);
Run Code Online (Sandbox Code Playgroud)
我期待185作为输出,但我得到0.
这里发生了什么?
我正在测试我的树枝模板中的数组中是否存在一个值
<input type="hidden" name="s" value="{{ search_value }}">
<label>
<input type="checkbox"
name="cat[]"
value="3"
onchange="this.form.submit()"
{% if 3 in cat ? ' checked' : '' %} >
<span>cbd</span>
</label>
{{ cat }}
Run Code Online (Sandbox Code Playgroud)
我{{ cat }}在页面上的转储数组,我确定我的问题是一个愚蠢的语法错误。我得到的错误是
致命错误:未捕获的异常:模板意外结束。在....
如果我以这种方式包装,我会得到一个不同的错误
{% (if 3 in cat) ? ' checked' : '' %} >
Fatal error: Uncaught Exception: A block must start with a tag name.
Run Code Online (Sandbox Code Playgroud)