今天在编程的时候,简单地用下边的程序求vector容器内的元素个数:vector vec;for (int i = 0; i vec_int;vector vec_char;vector vec_double;int size_vec_int = sizeof(vec_int);int siz...
分类:
编程语言 时间:
2015-02-27 00:17:15
阅读次数:
243
例子:char str[20]="0123456789"; char str2[20]="00"; char str3[] = {1,2,3,4,5,6}; char str4[] = {0,2,3,4,5,6}; char *str5 = str2; char *st...
分类:
其他好文 时间:
2015-02-26 16:18:51
阅读次数:
105
1 #include 2 #include 3 #include 4 #include 5 #define pf(x) printf("%d\n", x) 6 #define CL(x, y) memset(x, y, sizeof(x)) 7 #define max(a, b) (a >...
分类:
其他好文 时间:
2015-02-25 15:25:46
阅读次数:
147
strlen()和sizeof()的区别: strlen()——>C字符串库函数,返回字符串的真实长度。它是从内存某位置开始扫描,直到碰到结束符'\0'停止,返回计数器值。 sizeof()——>操作符,返回的是变量声明后“占用”的内存大小,可能不是实际大小。 int num; si...
分类:
编程语言 时间:
2015-02-25 14:12:24
阅读次数:
156
方法一:#include #include int main()
{ int **a = malloc(sizeof(int)*3); a[0]= malloc(sizeof(int)*2); a[1]= malloc(sizeof(int)*2); a[2]= malloc(sizeof(int)...
分类:
编程语言 时间:
2015-02-23 15:24:26
阅读次数:
224
#include#includetypedef struct STU{ char mID[15]; char mpass[15]; bool tag;}STU;STU arr[1010];int main(){ memset(arr,0,sizeof(arr)); int n,change...
分类:
其他好文 时间:
2015-02-21 16:37:26
阅读次数:
137
之前没有考虑到 两层都是 # 的情况#include#include#include#include#include#include#include#include#include#define mem(a,b) memset(a,b,sizeof(a))using namespace std;in...
分类:
其他好文 时间:
2015-02-20 21:58:54
阅读次数:
187
#include#include#includeint main(){ char in[90]; gets(in); char save[90][90]; memset(save,0,sizeof(save)); //【warning】memset一下,让最后是0,才不会一直输出“烫烫...
分类:
其他好文 时间:
2015-02-20 13:01:27
阅读次数:
168
定义一个字符数组:
char cArray[] = {'I','a','m','a','m','a','n','\0'};
用'\0'表示字符数组结束标志。它不占字符长度大小,但是占内存大小。
Result : sizeof(cArray) = 8 ; strlen(cArray) = 7 .
字符串定义方法:
(1)
char cString[] = "I am a Man !";...
分类:
编程语言 时间:
2015-02-20 11:57:46
阅读次数:
140
#include #include #include #include using namespace std;#define MAX 100#define LENGTH(a) (sizeof(a) / sizeof(a[0]))int visited[MAX];typedef struct _gr...
分类:
编程语言 时间:
2015-02-20 10:53:33
阅读次数:
220