这一直困扰着我.
struct person {
char name[15];
int age;
};
struct person me;
me.name = "nikol";
Run Code Online (Sandbox Code Playgroud)
当我编译时,我收到此错误:
错误:从类型'char*'分配类型'char [15]'时出现不兼容的类型
我错过了一些明显的东西吗?
我经常使用Guake终端模拟器.这是切片育成IMO以来最好的事情.
但有一件事一直困扰着我,当我想阅读手册页时,输出的默认宽度是终端窗口的宽度,在我的情况下总是全屏,所以它有点难以阅读.
有没有办法让man命令输出的默认宽度为a,阅读愉快,80个字符?
man的手册页有这一部分:
Run Code Online (Sandbox Code Playgroud)MANWIDTH If $MANWIDTH is set, its value is used as the line length for which manual pages should be formatted. If it is not set, manual pages will be formatted with a line length appropriate to the current terminal (using an ioctl(2) if available, the value of $COLUMNS, or falling back to 80 characters if neither is available). Cat pages will only be saved when the default formatting can be used, that is when the terminal …
我必须计算目录中的可执行文件数.
我已经想出了一种不同的方法(通过写入文件然后搜索文件,但这有点难看).
首先来到我的解决方案是这个(第一个参数是目录路径):
#!/bin/bash
noe=0
files=`ls -F $1` # because the -F option appends an indicator
# to the file, for an executable it's an '*'
# so if there is an executable 'script.sh' in the dir
# the output will be like this: 'script.sh*'
for i in $files
do
if [ `echo "$i" | grep '*$'` ] #should search for an '*' at the end...
then
let noe += 1
fi
done
echo $noe
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为for循环中省略了'*'.
(for循环中的echo命令最后输出一个没有'*'的文件名,但是当参数在""中时,在for循环外正常工作)
有关于这一个类似的问题在这里,我已经成功地回答适应我的情况,但它没有解释为什么它不能与完成.+我不完全理解为什么 …