linux下输出标准错误的方法
GNU glibc提供一个对printf的扩展,直接printf("%m"),可以输出标准的错误信息,例如下面:
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
int main()
{
if (open("/usr/test",0) < 0)
{
printf("%m \n");
printf("%s \n",strerror(errno));
}
return 0;
}
输出为 :
No such file or directory
No such file or directory
相关文档:
车水马龙,乱记点东西。
一开始不让我编译内核,结果是下面的问题导致:
1. sudo --- 拿root身份执行
2. apt-cache search ncurse --- 扫描所有带ncurse的资源
3. apt-get install libX-dev --- 安装开发用的lib库
4. cp -r --- 全面镜像复制
5. bz2 --- 压缩 tar jcvf 解压 tar jxvf
6. Ubuntu 生成 ......
网上关于fork()文章都说fork()来创建子进程,利用返回值的不同来执行不同的代吗段.但都没有说到如何实现不同的返回值.下面我将和你来说说这个问題:
考虑如下代码:
int &nb ......
Linux下转换字符集(UTF8转换)(转) 收藏
在LINUX上进行编码转换时,既可以利用iconv函数族编程实现,也可以利用iconv命令来实现,只不过后者是针对文件的,即将指定文件从一种编码转换为另一种编码。
一、利用iconv函数族进行编码转换
iconv函数族的头文件是iconv.h,使用前需包含之。
#include <iconv.h& ......
Linux, named after the inventor, Linus Torvalds, is a so different OS for everyone against Windows. To everyone who used to use Windows, Linux need us to do more for everything which we usually do by computer, such as playing a video.
Someone says, Linux is for the ones who are good at the computer ......