获取linux所有用户信息
#include <iostream>
#include <pwd.h>
#include <sys/types.h>
#include <stddef.h>
#include <string>
#include <list>
using namespace std;
void GetUser(list<string>& lsUser);
int main()
{
list<string> lsUser;
GetUser(lsUser);
cout << "all user name in current computer:" << endl;
list<string>::iterator it;
for (it = lsUser.begin(); it != lsUser.end(); it++)
{
cout << it->c_str()<< endl;
}
return 0;
}
void GetUser(list<string>& lsUser)
{
struct passwd* pstPwd = NULL;
setpwent();
while ( (pstPwd = getpwent()) != NULL )
{
lsUser.push_front(pstPwd->pw_name);
}
endpwent();
}
相关文档:
1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI) 就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......
一:前言
最近在研究android的sensor driver,主要是E-compass,其中用到了Linux input子系统.在网上也看了很多这方面的资料,感觉还是这篇分析的比较细致透彻,因此转载一下以便自己学习,同时和大家分享!
(这篇博客主要是以键盘驱动为例的,不过讲解的是Linux Input Subsystem,可以仔细的研究一下!)
键盘驱动将检 ......
在Linux下进行C语言编程,必然要采用GNU GCC来编译C源代码生成可执行程序。Gcc指令的一般格式为:
Gcc [选项] 要编译的文件 [选项] [目标文件]。其中,目标文件可缺省,Gcc默认生成可执行的文件名为:编译文件.out
看一下经典入门程序"Hello World!"
# vi hello.c ,编辑如下:
#inclu ......
Wget是一个十分常用命令行下载工具,多数Linux发行版本都默认包含这个工具。如果没有安装可在 http: //www.gnu.org/software/wget/wget.html 下载最新版本,并使用如下命令编译安装:
# tar zxvf wget-1.9.1.tar.gz
# cd wget-1.9.1
# ./configure
# make
# make install
它的用法很简单.
1)支持断点下 ......
操作系统的一个经典问题是"生产者-消费者"问题, 这涉及同步信号量和互斥信号量的应用, 在这里,我用线程的同步和互斥来实现.
/*
* author 张文
* 2008/06/20
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h> ......