码:
int fd;
fd = open("fruit", O_WRONLY);
write(fd, "apple", sizeof("apple"));
close(fd);
Run Code Online (Sandbox Code Playgroud)
我用它编译它
$ gcc test.c -o test
Run Code Online (Sandbox Code Playgroud)
并运行
$ ./test
Run Code Online (Sandbox Code Playgroud)
然后我打开fruit文件,我在文件中看到以下内容:
apple^@
Run Code Online (Sandbox Code Playgroud)
什么^@意思?
/etc/profileCentOS 6上的文件中有一个for循环:
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done
Run Code Online (Sandbox Code Playgroud)
${-#*i}上面的循环意味着什么?
谢谢你的帮助.
我不确定在初始化后以下列方式在char数组中会出现什么:
char buf[5]={0,};
Run Code Online (Sandbox Code Playgroud)
这相当于
char buf[5]={0,0,0,0,0};
Run Code Online (Sandbox Code Playgroud) 我对以下代码感到困惑:
#include <iostream>
int i = 1;
int main()
{
int i = i;
std::cout << "i: " << i << "\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
i: 0
Run Code Online (Sandbox Code Playgroud)
我曾预计运行上面的代码会打印出来1.有人可以解释这种奇怪行为的原因吗?
假设层次结构的所有类都实现了模板成员函数g.所有类共享两个其他函数的相同实现,f1并f2调用此模板:
struct A {
virtual void f1() {
g(5);
}
virtual void f2() {
g(5.5);
}
private:
template <typename T> void g(T) {std::cout << "In A" << std::endl;}
};
struct B: A {
// Can I get rid of this duplicate code?
virtual void f1() {
g(5);
}
virtual void f2() {
g(5.5);
}
private:
template <typename T> void g(T) {std::cout << "In B" << std::endl;}
};
struct C: A {
// Can I …Run Code Online (Sandbox Code Playgroud) 我对以下命令感到困惑
$ cat num.txt
1
2
3
1st
2nd
3th
$ cat num.txt | grep -Eo '[0-9](?:st|nd|th)?'
Run Code Online (Sandbox Code Playgroud)
我认为它应该输出为
1
2
3
1
2
3
Run Code Online (Sandbox Code Playgroud)
但它输出为
1
2
3
1
2nd
3th
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?感谢您的帮助。
运行 Debian 杰西
我使用以下过程安装了 Ansible:
apt-get update
sudo apt-get install python-yaml python-pip python-jinja2 python-paramiko pip
git clone https://github.com/ansible/ansible.git
cd ansible
git submodule update --init --recursive
sudo make install
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以干净地卸载 Ansible,而不涉及筛选我的目录树并删除?
目的是重新安装 Ansible 版本 1.9 而不是最新的 2.1.0
我意识到有些方法应该用 来调用(),而另一些则不能。我如何使用 IPython 检查是否使用括号?例如下面的文件scratch.py
import numpy as np
arr = np.random.randn(5)
print arr.sort, "\n"
print arr.sort(), "\n";
print arr.shape, "\n";
print arr.shape(), "\n";
Run Code Online (Sandbox Code Playgroud)
产生这个输出:
<built-in method sort of numpy.ndarray object at 0x7fb4b5312300>
None
(5,)
Traceback (most recent call last):
File "scratch.py", line 8, in <module>
print arr.shape(), "\n";
TypeError: 'tuple' object is not callable
Run Code Online (Sandbox Code Playgroud) 我对以下代码片段感到困惑:
#!/bin/bash
H=$(date +%H);
if (( 10#$H > 5 ))
then
# do something
else
# do something else
fi
Run Code Online (Sandbox Code Playgroud)
(( 10#$H > 5 ))上面代码片段的含义是什么?
我的程序:
#!/usr/bin/perl
use strict;
use warnings;
use Dancer2;
$| = 1;
set host => '127.0.0.1';
set port => 7071;
get '/foo' => sub {
`sleep 5`;
'ok'
};
start;
Run Code Online (Sandbox Code Playgroud)
然后我运行以下for循环:
for i in $(seq 1 3)
> do
> time curl http://localhost:7071/foo &
> done
Run Code Online (Sandbox Code Playgroud)
输出:
ok
real 0m5.032s
user 0m0.013s
sys 0m0.000s
ok
real 0m10.037s
user 0m0.012s
sys 0m0.000s
ok
real 0m15.043s
user 0m0.004s
sys 0m0.008s
Run Code Online (Sandbox Code Playgroud)
看来Dancer2一次只能接受一个请求,如何允许多个连接到Dancer2?