- 博客(11)
- 问答 (1)
- 收藏
- 关注
原创 c++实现strcspn()函数的功能
#includeusing namespace std;int str_cspn(char *c1,char *c2){ int i=0; int j=0; while(*(c1+i)!='\0') { while(*(c2+j)!='\0'&&(*(c1+i)!=*(c2+j))) { j++; } if(*(c1+i)==*(c2+j)) break
2014-07-31 16:01:02 1194
原创 memset()函数简单用法
#include#includeusing namespace std;int main(){ char s[20]; memset(s,0,sizeof(char)*20); memcpy(s,"abcdefghi",9); //strcpy_s(s,"abcdefghi"); cout<<s<<endl; system("pause"); return 0;}
2014-07-31 10:59:55 1026
原创 c++公用体union、结构体struct内存分配问题
#include#include#includeusing namespace std;union data{ char c1; //字符型占1字节 int n; //整型占4字节 double c2; //公用体最大基础类型是double,8字节,以8对齐, char c3[9]; //字符数组占9字节 ,9>8,所以该公用体占8*2=16字节}
2014-07-29 23:38:34 1189
原创 c++实现字符串复制函数strcpy()
#include#includeusing namespace std;char *str_cpy(char *dest,char s[]){ char *p=s; char *q=dest; int m=strlen(s); while(m--!=0) { *q++=*p++; } *q='\0'; return dest;}in
2014-07-29 21:52:25 6904
原创 sizeof()与strlen()函数计算的总结
#include#include#includevoid fun(char str[100]){ printf("%d\n",sizeof(str));//8 同p2}int main(){ char str[]="hello"; char *p1=str; int n=10; char *p2=(char*)malloc(100); pri
2014-07-29 15:12:58 767
原创 排序--选择法
//选择排序#includeusing namespace std;void selectsort(int a[],int n){ int temp; for(int i=0;i<n;i++) { for(int j=i+1;j<n+1;j++) { if(a[i]>a[j])//第一位与其他所有数比较,比第一位大则交换,永远使第一位最小
2014-07-27 23:04:03 674
原创 排序--冒泡法
//冒泡排序#includeusing namespace std;void maopaopx(int a[],int n){ int temp; for(int i=0;i<n;i++)//i用来控制比较的次数 { for(int j=0;j<n-i;j++)//j用来进行前后两个数的比较,j比较的次数由i控制 { if(a[j]>a[j+1]
2014-07-27 23:01:18 770
原创 排序--快速排序法
//快速排序法#include using namespace std; void Qsort(int a[],int low,int high){ if(low>=high) { return; } int first=low;//0 int last=high;//8 int key
2014-07-27 22:57:36 752
原创 c++实现字符串strcat()连接
//字符串连接函数#include#includeusing namespace std;char *string_cat(char *source,int s1,const char *dest){ int i,j; i=s1; for(j=0;dest[j]!=0;j++,i++) //从数组s1的位置处开始加入新的字符 {
2014-07-27 22:51:02 11301
原创 c++实现统计字符串中各字符的个数
#include#includeusing namespace std;void tongji(char*,int);int main(){char a[100];cout<<"请输入字符串:";gets_s(a);int n=strlen(a);cout<<"输出字符串:"<<endl;cout<<a<<endl;tongji(a,n);system("pause");return 0;}voi
2014-07-27 22:26:56 17812 6
空空如也
使用C++利用POST模拟登录某个网站后,如何获取Cookie?
2014-12-03
TA创建的收藏夹 TA关注的收藏夹
TA关注的人