码迷,mamicode.com
首页 >  
搜索关键字:char    ( 35907个结果
sscanf的应用
1.提取字符串2.提取指定长度的字符串3.提取指定字符为止的字符串4.取仅包含指定字符集的字符串5.取到指定字符集为止的字符串#include int main(){ char str[512]={0}; sscanf("123456","%s",str); printf("str...
分类:其他好文   时间:2014-05-12 17:15:19    阅读次数:322
字符串的逆序
普通排序:直接分配一个同等大小的数组,反向copy即可.char* Reverse(char* s){ //将q指向字符串最后一个字符 char* q = s ; while( *q++ ) ; q -= 2 ; //分配空间,存储逆序后的字符串。 char* p = newchar[sizeof(...
分类:其他好文   时间:2014-05-12 16:30:14    阅读次数:338
关于内存对齐
一.内存对齐的初步讲解内存对齐可以用一句话来概括:“数据项只能存储在地址是数据项大小的整数倍的内存位置上”例如int类型占用4个字节,地址只能在0,4,8等位置上。例1:#include struct xx{ char b; int a; int c; char d;};int main(){ st...
分类:其他好文   时间:2014-05-10 19:52:54    阅读次数:323
C++ string中的几个小陷阱,你掉进过吗?
C++开发的项目难免会用到STL的string,使用管理都比char数组(指针)方便的多,但在得心应手的使用过程中也要警惕几个小陷阱,避免我们项目出bug却迟迟找不到原因。1. 结构体中的string赋值问题直接通过一个例子说明,下面的例子会输出什么:#include #include #i...
分类:编程语言   时间:2014-05-05 23:33:45    阅读次数:413
用fseek和ftell获取文件的大小
#include #include #include int main(int argc,char *argv[]){ int n=0; FILE *fp; if((fp=fopen(argv[1],"r"))==NULL) { perror("fopen");...
分类:其他好文   时间:2014-05-02 18:05:54    阅读次数:308
ecl函数的用法
相关函数fork, execle, execlp, execv, execve, execvpWindows下头文件#include Linux下头文件#include 函数定义int execl(const char *path, const char *arg, ...);函数说明execl()...
分类:其他好文   时间:2014-05-02 17:52:52    阅读次数:674
拷贝构造函数[c++]
拷贝构造函数何时会被调用?1. 对象以值传递的方式传入函数参数2.对象以值传递的方式从函数返回3.对象需要通过另外一个对象进行初始化下面我们来看代码://#include //using namespace std;//template //T:队列的类型,char,int,double,包括自己....
分类:编程语言   时间:2014-05-02 17:33:17    阅读次数:401
printf/scanf格式
(1)打印字符char c;printf("%c",c);(2)打印整形int i;printf("%d",i); //有符号十进制数printf("%u",i); //无符号十进制数(3)打印浮点数float f;printf("%f",f);(4)打印指针int *p;pri...
分类:其他好文   时间:2014-05-02 16:13:07    阅读次数:378
用fread和fwrite实现文件复制操作
#include #include #include int main(int argc,char **argv){ FILE *fp_src,*fp_des; char buf[128]; int num; if(argc!=3) { printf("t...
分类:其他好文   时间:2014-05-02 16:06:36    阅读次数:562
获取CPU频率
#include #include float get_cpu_clock_speed(){ FILE *fp; char buffer[1024]; size_t bytes_read; char *match; float clock_speed; fp=fo...
分类:其他好文   时间:2014-05-02 14:20:39    阅读次数:392
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!