易截截图软件、单文件、免安装、纯绿色、仅160KB

linux控制台显示中文

#include <stdio.h>
#include <wchar.h>
#include <locale.h>
int main()
{
#ifdef _WIN32
  setlocale(LC_ALL, "chs");
#else
  setlocale(LC_ALL, "zh_CN.UTF-8");
#endif
  wchar_t KZg[] = {0x6211, 0};
  char buf[10] = {0};
  wcstombs(buf,KZg,10);
  printf("_%s_\n",buf);
}
wchar_t 在linux上是4个字节, 在win32上是2个字节, MinGW也是2个字节.
一般会节省空间使用utf-16.
#ifdef _WIN32
  typedef wchar_t uchar;
#else
  typedef unsigned short uchar; // 就不能使用string.h提供的宽字符串方法了.
#endif
linux上使用string常量只能用{}.


相关文档:

Linux下 c 判断一个文件是否存在

#include <stdio.h>
#include <unistd.h>
#define FOO "foo"
int main(void)
{
if(!access(FOO, F_OK))
{
if(!unlink(FOO))
{

}
else
{
printf("remove %s failed\n", FOO);
}
}
else
{
printf("%s not existed\ ......

Linux下RPC的hello world

Linux 下面使用RPC需要使用到命令rpcgen.
在Linux下开发RPC程序流程如下:
1.写一个rpc程序,
       如test.x
2.使用rpcgen生成必须的文件,通常是客户端和服务器端以及头文件
       $rpcgen test.x
3.使用rpcgen生成服务器端和客户端的C语言代码
&n ......

列出Linux源码下所有Makefile的方法

 一、要求:
1、能够显示出Makefile的总数
2、能显示一级目录下的Makefile总数、Makefile列表及其Makefile的内容
3、能将上述内容写入相应的文件
二、实例
rm -rf ~/Desktop/linux_Makefile/*
for i in `find . -maxdepth 1 -type d`
#仅仅是当前目录,所以请将本脚本放在linux源码目录下执行。
do
 e ......

linux内核空间申请超过2MB连续空间的实现函数。

 /*
kmalloc can apply 128KB memory only. This func support any continous memory allocate more than 2MB.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kallsyms.h>
#define KMEM_PAGES       &nb ......

关于linux下的软链接和硬链接

 连接上了服务器,检查一下。磁盘空间不够了
[java@localhost ~]$ df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/hda2 5.8G 5.8G 0M 100% /
/dev/hda1 99M 8.5M 86M 10% /boot
none 506M 0 506M 0% /dev/shm
/dev/hda6 20G 77M 19G 1% /tmp
/dev/hda5 20G 14G 5.2G 72% /usr/local
/dev/hd ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号