C/C++ 软件列表

c语言中用字符串数组显示菜单的解决方法
C/C++

c语言中用字符串数组显示菜单的解决方法

2020-02-16 标签:c,语言,中用,字符串,数组,显示,菜单,解决方法,以前,方面,东西,往往,重复,发现,方法,还可以,指针,解决,遍历,问题

以前写菜单方面东西时往往重复, 发现这个方法还可以, 用一个指针的指针解决遍历问题.代码如下所示:实现代码如下:#include static char *menu[] = {"1 --- push one item./n","2 --- pop one item./n","3 --- quit./

如何用C语言生成简单格式的xml
C/C++

如何用C语言生成简单格式的xml

2020-02-16 标签:如何,c,语言,生成,简单,格式,xml,代码,很简单,直接,实现,如下,include,stdio,h,static,file,null,int

代码很简单,直接贴了。实现代码如下:#include static FILE *out = NULL;static int tabs = 0;void set_out_fp(FILE *fp){out = fp;}void put(char *str){fprintf(out, "%s", str)

基于C++输出指针自增(++)运算的示例分析
C/C++

基于C++输出指针自增(++)运算的示例分析

2020-02-16 标签:基于,c,输出,指针,运算,示例,分析,实现,代码,如下,include,stdafx,h,iostream,using,n,amespace,std

实现代码如下:#include "stdafx.h"#include using namespace std;int _tmain(int argc, _TCHAR* argv[]){ char s[] = "012345678", *p = s; cout << "s:"<<

基于C++ list中erase与remove函数的使用详解
C/C++

基于C++ list中erase与remove函数的使用详解

2020-02-16 标签:基于,c,list,erase,remove,函数,使用,详解,作用,作为,参数,失效,返回,指向,下一

erase的作用是,使作为参数的迭代器失效,并返回指向该迭代器下一参数的迭代器。如下:实现代码如下:list ParticleSystem;list::iterator pointer;if(pointer->dead == true){pointer = ParticleSystem.era

用c语言根据可变参数合成字符串的实现代码
C/C++

用c语言根据可变参数合成字符串的实现代码

2020-02-16 标签:c,语言,根据,可变,参数,合成,字符串,实现,代码,经常,需要,值得,特定,每次,调用,vsprintf,malloc,很烦,以下

写代码时, 经常需要根据参数值得到一特定的字符串. 每次都调用vsprintf, malloc很烦. 以下是一个实现了此功能的接口.实现代码如下:#include #include #include #include char *xm_vsprintf_ex(int len, char *fmt,

基于C语言fflush()函数的使用详解
C/C++

基于C语言fflush()函数的使用详解

2020-02-16 标签:基于,c,语言,fflush,函数,使用,详解,用于,清空,缓冲,一般,感觉,不到,默认,printf,输出,stdout,就会

fflush用于清空缓冲流,虽然一般感觉不到,但是默认printf是缓冲输出的。 fflush(stdout),使stdout清空,就会立刻输出所有在缓冲区的内容。 fflush(stdout)这个例子可能不太明显,但对stdin很明显。 如下语句: int a,c; scanf("%d", c=g

如何用C语言去除字符串两边的空字符
C/C++

如何用C语言去除字符串两边的空字符

2020-02-16 标签:如何,c,语言,去除,字符串,两边,字符,今天在,一国,外网,站上,下面,代码,精简,实现,如下,char,tr

今天在一国外网站上, 看到下面的代码, 觉得挺精简. 实现代码如下:char *tr ( char *s ){int i = 0;int j = strlen ( s ) - 1;int k = 0;while ( isspace ( s[i] ) while ( isspace ( s[j] )

用c语言实现HUP信号重启进程的方法
C/C++

用c语言实现HUP信号重启进程的方法

2020-02-16 标签:c,语言,实现,hup,信号,重启,进程,方法,代码,如下,所示,include,stdio,h,string,stdlib,signal,unistd,errno,syslog

代码如下所示:实现代码如下:#include #include #include #include #include #include #include #include char **bak_argv;int flag = 0;void restart(void);void sighup_hand

C语言字符串操作总结大全(超详细)
C/C++

C语言字符串操作总结大全(超详细)

2020-02-16 标签:c,语言,字符串,操作,总结,大全,详细,strcpy,p,复制,strncpy,n,指定,长度,strcat,附加,strncat,strlen

1)字符串操作 strcpy(p, p1) 复制字符串 strncpy(p, p1, n) 复制指定长度字符串 strcat(p, p1) 附加字符串 strncat(p, p1, n) 附加指定长度字符串 strlen(p) 取字符串长度 strcmp(p, p1) 比较字符串 strcasecm

解析如何在C语言中调用shell命令的实现方法
C/C++

解析如何在C语言中调用shell命令的实现方法

2020-02-16 标签:解析,如何,c,语言,调用,shell,命令,实现,方法,system,执行,相关,函数,fork,execve,waitpid,popen,表头,文件

1、system(执行shell 命令)相关函数 fork,execve,waitpid,popen表头文件 #include定义函数 int system(const char * string);函数说明 system()会调用fork()产生子进程,由子进程来调用/bin/sh-cstring