- 博客(35)
- 资源 (5)
- 收藏
- 关注
转载 typedef 函数指针
#include <stdio.h>typedef char (*PTRFUN)(int); //typedef 定义一个新类型 类型为指针 //该指针指向一个函数 该函数一个int参数 返回值未charPTRFUN pFun; //新类型PTRFUN 该类型声明了一个pFun变量 char glFun(int a){ printf("%d\n",a);}int main(){...
2022-03-10 09:38:32 101
转载 获得文件状态信息
#include//C++ 获得文件状态信息源码,C++ 获得文件所在磁盘盘符源码,C++ 文件创建时间源码,C++ 访问时间源码,C++ 最后修改日期源码,No such file or directory(无此文件或索引)#include #include #include #include using namespace std;void main( void
2015-10-16 15:24:29 421
转载 数组,指针sizeof
#includeusing namespace std;void main(){ char A[4]; char *B="abcdefg"; void *c; c=new char[100]; cout cout cout cout cout //cout}
2015-10-15 16:16:03 288
转载 用指针的方法交换变量
#includeusing namespace std;void swap(int *p1,int *p2){ int temp; temp=*p1; *p1=*p2; *p2=temp; cout}int main(){ int i=3,j=5; swap(&i,&j); cout return 0;
2015-10-15 16:08:02 381
转载 指针应用
#includeusing namespace std;void main(){ int *p; int begin,end; begin = 10; p=&begin; end=*p; cout cout cout cout}
2015-10-15 16:02:32 204
转载 参数为函数指针
#includeusing namespace std;int get_v(int a, int b, int(*sub)(int,int)){ return sub(a,b);}int max(int a,int b){return ((a>b)?a:b);}int min(int a, int b){return ((a}
2015-10-15 15:50:11 229
转载 动态地分配内存
#includeusing namespace std;void main(){ char ch='A'; int *p1; p1=new int(100); cout delete p1;}/*-------------------------------------------------●动态分配符○new 和dele
2015-10-15 15:31:07 299
转载 指针的应用
#includeusing namespace std;void main(){ int *x,*y,*temp; int a,b; x=&a; y=&b; cin>>a>>b; temp=x; x=y; y=temp; cout cout cout cou
2015-10-15 15:16:36 211
转载 指针设计类和对象回应程序
#includeusing namespace std;void main(){ int a,b; int *x,*y,*temp; cin>>a>>b; x=&a; y=&b; temp=x; x=y; y=temp; cout}
2015-10-15 15:06:40 206
转载 指针
#include#includeusing namespace std;class Welcome{private:char *str;public:void Talk();};void Welcome::Talk(){ str=new char[100]; for(;;) {coutgets(str);i
2015-10-15 14:59:44 199
转载 指针设计类和对象回应程序
#include #include using namespace std;class Welcome{private:char *str;public:void Set(char *);void Display();char *Get();void Talk();Welcome(Welcome&);Welcome(char *str="hi")
2015-10-14 11:43:51 316
转载 this->指针
#include using namespace std;class point{public:int a;int b;point(int x,int y){a=x;b=y;}void output(int a,int b) { this->a=a;this->b=b; }void output()
2015-10-14 10:39:22 368
转载 使用指针变量
#includeusing namespace std;int main(){ int a[10]; int i,*p; for(i=0;ia[i]=i+1; for(p=a;pcout cout return 0;}
2015-10-14 10:16:05 304
转载 使用数组名和指针运算
#includeusing namespace std;int main(){ int a[10]; int i; for(i=0;i { a[i]=i+1;cout } cout return 0;}
2015-10-14 10:03:16 415
转载 拷贝对象资源,this指针
#includeusing namespace std;class student{public:student(char *pName="no name",int ssID=0){ id=ssID; name=new char[strlen(pName)+1]; strcpy(name,pName); cout};void copy
2015-10-13 10:25:07 330
转载 字符整型指针
#includeusing namespace std;void main(){struct test{char *str;int *ip;}x;x.ip=new int;*(x.ip)=100;coutdelete x.ip;x.ip=new int[5];for(int i=0;i*(x.ip+i)
2015-10-13 09:47:52 279
转载 结构指针和数组
#includeusing namespace std;void main(){struct human{char name[10];int sex;int age;};human x[]={{"weiping",1,30},{"lihuan",1,25},{"liumin",0,23}};human *p=NULL;for(int i=0;i
2015-10-12 09:49:50 223
转载 改变指针指向的字符内容、动态分配字符型指针变量内存空间
#includeusing namespace std;int main(){ char str[10]; char *strip=str; cout cin>>str; cout cout cout cin>>strip; cout cout *(strip+2)='|'; cout cout strip=new cha
2015-10-12 09:32:38 470
转载 指针赋值、自增自减、组合和关系运算
#includeusing namespace std;int main(){int a[]={1,2,3,4,5,6};int *ip1,*ip2;ip1=a;ip2=ip1;coutcout ip1++;ip2+=4;coutcoutint n=ip2>ip1;coutcout n=
2015-10-08 11:51:24 395
转载 二元数组中的指针
#includeusing namespace std;int main(){ int a[2][3],i,j; int *ip; for(i=0;i for(j=0;j { coutcin>>a[i][j]; } ip=&a[0][0]; for(i=0;i for(j=0;j { cout
2015-10-08 11:34:07 418
转载 指针工作原理
#includeusing namespace std;int main(){ int a,b,*ip; a=456; ip=&a; cout cout cout ip=&b; b=123; cout cout cout cout cout cout cout cou
2015-10-08 11:19:43 901
转载 拼接两个顺序文件a.txt和b.txt的内容,结果保存在a.txt(未成功)
#include#include#include#includeusing namespace std;int main(){ char str[100]; int i=0,rsLength=0,rs2Length=0; fstream rs; rs.open("a.txt",ios::app); if(!rs) { co
2015-09-30 13:32:45 654
转载 显示(读取)文件大小
#include#includeusing namespace std;void main(){ char fname[365]; cout cin>>fname; ifstream rs(fname,ios::app|ios::in); try { if(rs.fail()) throw "error!"; } catch(char
2015-09-30 11:26:52 247
转载 浏览文本文件
#include#include#include#includeusing namespace std;int main(){ fstream rs; char fn[150],buf[1000]; cout cin>>fn; rs.open(fn,ios::app|ios::in); if(!rs) { c
2015-09-30 11:13:25 257
转载 复制文件
#include#includeusing namespace std;int main(){ fstream rs,rs2; char f1[100],f2[100],ch; cout cin>>f1; cout cin>>f2; rs.open(f1,ios::in); rs2.open(f2,ios::out); whil
2015-09-30 10:21:37 1115
转载 read()从二进制文件读取指定记录号的数据
#include#includeusing namespace std;int main(){ int i=0,a[10];// int a[10]={0};//for(int i=0;i<9;i++)//{//a[i+1]=a[i]*20+i+1;//cout<<a[i]<<endl;//}//ofstream rs1("ok2002com.txt
2015-09-30 10:02:47 2243
转载 write()二进制方式写文件
#include#includeusing namespace std;int main(){int a[10]={0};for(int i=0;i{a[i+1]=a[i]*10+i+1;cout}ofstream rs("ok2002com.txt");ofstream rs2("ok2002com.bin",ios::binary);for(
2015-09-30 09:46:24 3430
转载 删除文件夹(目录)
#include//C++ 删除文件夹源码,C++ 删除目录源程序#includeusing namespace std;int main(){ //if(mkdir("c:\\ok2002com")) // cout if (rmdir("c:\\ok2002com")==-1) cout else//在D盘删除名为ok2002com的文件夹
2015-09-29 17:01:37 364
转载 读取当前所在目录(文件夹)(C/C++源程序)
#include#include#define MAX_PATH 250using namespace std;int main() { char *p,str[MAX_PATH]; if((p=getcwd(str,MAX_PATH))==NULL) { cout } else { cout
2015-09-29 17:00:31 1011
转载 更改目录,返回指定文件夹(C/C++源程序)
#include#includeusing namespace std;int main(){ if(chdir("C:\\ok2002")) { cout }}
2015-09-29 16:59:22 351
转载 put()函数把数据顺序写入文件
#include#include using namespace std; int main() { char *str="http://www.ok2002.com"; ofstream rs; rs.open("c:\\file3.txt",ios::out); if(!rs) { cout return 0; } f
2015-09-29 16:55:38 435
转载 get()函数读顺序文件(C/C++源程序)
#include#includeusing namespace std;int main(){ char str[100]; int i=0; ifstream rs; rs.open("file2.txt",ios::in); if(!rs) { cout return 0; } while(rs) { rs.get(str[
2015-09-29 16:54:05 588
转载 定义文件流对象,统计字符个数(C/C++源程序)
#include#includeusing namespace std;int main(){ char *str=" I study C++ in ok2002.com"; int count_k=0,count_all=0; ofstream rs; rs.open("ok2002.txt",ios::out); if(!rs) cout for(
2015-09-29 16:52:06 411
转载 文件逆序(倒读),文件长度
#include#includeusing namespace std;int main(){ int i=0,j=0,len=0; char str[100]; ifstream rs("ok2002com.txt"); if(!rs) cout while(rs>>str[i]) { len++; i++; } cout
2015-09-29 16:43:36 627
原创 个人博客开启(导语篇)
因在学习C/C++过程中遇到一些问题,为便于以后查阅和保存近日开启个人博客。 之前在论坛或者网站上看到一些代码有误或者VS版本问题变出错,特记录自己学习过程中修改并调试成功的程序源码,为不产生不必要的纠纷与麻烦顾所有帖子均注明为转载。--------2015年9月29号
2015-09-29 16:42:17 305
Node.js实战 第2季 [吴中骅著].pdf
2018-05-03
面试读-经典嵌入式面试题
2018-01-04
C语言嵌入式典试题全部在这里
2018-01-04
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人