C++/C
文章平均质量分 56
iteye_19635
这个作者很懒,什么都没留下…
展开
-
qsort的七种排序
七种qsort排序方法 <本文中排序都是采用的从小到大排序> 一、对int类型数组排序 int num[100]; Sample: int cmp ( const void *a , const void *b ) { return *(int *)a - *(int *)b; } qsort(num,1...原创 2008-12-20 19:17:27 · 89 阅读 · 0 评论 -
从字符串s1 中删除所有在s2里出现的字符 squeeze
Write a alternate version of squeeze(s1,s2) that deletes each characters in s1 that maths any character in string s2 #include <stdio.h>/*字符串s1 中删除所有在s2里出现的字符*/void squeeze(char s1[],cha...2008-10-22 16:40:27 · 1255 阅读 · 0 评论 -
自己写strcat函数,有点小问题
reading the book of 《the C programing language》,write a program by myself about strcat,but here is a mistake. I recode the program here in order to find the causation in future. #include <std...2008-10-22 15:53:52 · 137 阅读 · 0 评论 -
Convert a String of hexademical digits into a Int
<<The C programming language>> has an Exercise. Convert a String of hexademical digits into a Int. #include <stdio.h>int hexaDecimalToDecimal(char s[]){ if(s[0]!='0')...2008-10-22 13:47:41 · 257 阅读 · 0 评论 -
Reading The C Programing Language-Counting words
A simple Programing: Couting the lines,words,charcaters in INPUT.#include <stdio.h>#define IN 0; // inside a word#define OUT 1;//outside a word/* couting the words,lines,characters in I...2008-10-18 20:35:35 · 90 阅读 · 0 评论 -
Note: EOF The C programming language,
Reading <<The C programming luange>>,a pragram #include <stdio.h>main(){ int c; while((c=getchar())!=EOF) { putchar(c); }} 1. EOF means ...2008-10-18 16:39:43 · 57 阅读 · 0 评论 -
字符数组
看下段代码输出结果#include<iostream.h>#include<string.h>void main(void){char s1[]="hello";char s2[]={'h','e','l','l','o'};cout<<strcmp(s1,s2);} 结果为:-1 解释:1. 字符数组,相当于字符串,后面会自动...2008-10-16 12:47:30 · 96 阅读 · 0 评论 -
getKey
#include <iostream>#include <fstream>#include <afx.h>#include <string>using namespace std;int WCharToChar(UINT PageCode, std::wstring strWChar, std::string &s...原创 2009-06-30 21:31:23 · 216 阅读 · 0 评论 -
读书笔记,(杂)
引用与指针的区别:1. 引用必须被初始化。指针可以不初始化。 int a; int & b = a; int * pi; 引用初始化有种特殊情况。const引用。 const int & a = 0; const int & b =2.2;2. 用一个指针给另外一个指针赋值,改变的指针;用一个引用给另外个引用赋值,...原创 2009-06-02 22:45:29 · 86 阅读 · 0 评论 -
strlen与sizeof的区别
strlen与sizeof的区别1.sizeof操作符的结果类型是size_t,它在头文件中typedef为unsigned int类型。该类型保证能容纳实现所建立的最大对象的字节大小。 2.sizeof是算符,strlen是函数。 3.sizeof可以用类型做参数,strlen只能用char*做参数,且必须是以''\0''结尾的。4.数组做sizeof的参数不退化,传递给...原创 2009-05-26 09:44:27 · 63 阅读 · 0 评论 -
读“虚函数在对象中的内存布局”
http://blog.sina.com.cn/s/blog_5f5fff010100cv90.html 总结:1. 就内存空间的分配而言,函数是类拥有的;而成员变量和虚函数是对象所拥有的。2.继承使得祖先的成员变量(不管是不是私有的)在子类的对象中。3.对象存在且仅存在一个指向虚函数表的指针。(即使有多个虚函数)...2009-05-04 20:11:39 · 79 阅读 · 0 评论 -
memcpy memmove 区别
memcpy 和memmove 都是把一个内存块拷贝到另一个内存块,其区别为: memcpy 不考虑源内存块和 目标内存块 是否重叠的情况,即 source | | dest | | 而m...2009-04-19 15:43:33 · 81 阅读 · 0 评论 -
char * 与 char []
There is an important difference between these definitions: char amessage[] = "now is the time"; /* an array */ char *pmessage = "now is the time"; /* a pointer */amessage is an array, just big e...2009-12-15 20:46:18 · 221 阅读 · 0 评论 -
浮点型(float,double)判断是否为0
无论float 还是double 都有精度 限制,故当浮点型数值 与 0 进行比较,应取一精度值,在此精度允许的范围内,看是否与0相等。 例如:const double EPSINON = 0.000001double var;if(var < EPSINON && var > - EPSINON) //"var = 0...2009-04-03 12:09:12 · 2287 阅读 · 0 评论 -
scanf sscanf的用法
sscanfhttp://baike.baidu.com/view/1364018.htm 名称: sscanf() - 从一个字符串中读进与指定格式相符的数据. 函数原型: Int sscanf( string str, string fmt, mixed var1, mixed var2 ... ); int scanf( const char *...原创 2008-12-26 11:06:04 · 62 阅读 · 0 评论 -
memcopy 和memmove
1.memmove函数原型:void *memmove(void *dest, const void *source, size_t count)返回值说明:返回指向dest的void *指针参数说明:dest,source分别为目标串和源串的首地址。count为要移动的字符的个数函数说明:memmove用于从source拷贝count个字符到dest,如果目标区域和源区域有重叠的...原创 2008-12-21 14:29:55 · 79 阅读 · 0 评论 -
c语言字符串操作大全
函数名: strcpy功 能: 拷贝一个字符串到另一个字符串用 法: char *strcpy(char *destin, char *source);程序例: #i nclude <stdio.h>#i nclude <string.h>int main(void) { char string[10]; char *str1 = "abcd...原创 2008-12-21 13:50:19 · 64 阅读 · 0 评论 -
%f 与 %lf的区别
%f是单精度浮点型,输出的时候要满足6位小数。 %lf就是输出数值总长度为L,整数个数加小数个数,不足补空,右顶格起 %f和%lf对scanf来说有差别,%f用于float,%lf用于double 在printf中,%f用于float和double,因为float会自动转为double,另外,%lf对于printf在C89标准中无定义...2008-12-21 11:59:45 · 5360 阅读 · 0 评论 -
在北邮 bbs上看到一个理解指针,指针数组不错的题目
#include <stdio.h>int main(void) { int a[]={1,2,3,4,5}; int * p=(int *)&a+1; printf("*(a+1)=%d\n",*(a+1)); printf("*p=%d",*(p-1));-} 输出为:*(a+1)=2*p=5 Explain: a的类...2008-10-27 20:29:02 · 66 阅读 · 0 评论