指针函数:
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
/*
定义指针函数
*/
int* add(int a, int b){
int res=a+b;
//传入地址
return &res;
}
int main(){
//返回地址
cout<<add(1,2)<<endl;
//返回结果(值)
cout<<*add(1,2)<<endl;
return 0;
}
文件操作:
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
FILE *f;
int main(){
//r+是可读写(文件必须存在)
//w+可以读写 (不存在时创建)
//r是只能读 w是只能写 如果做了其他操作不会报错 但是不成功
//f=fopen("文件名.txt","方式")打开 fclose(f)关闭
f=fopen("1.txt","r+");
int a;
while(fscanf(f,"%d",&a)!=EOF){
cout<<a<<" ";
}
cout<<endl;
char c;
while(fscanf(f,"%c\t",&c)!=EOF){
cout<<c<<" ";
}
fprintf(f,"%d\t",100);
fclose(f);
return 0;
}