1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| #include<bits/stdc++.h> using namespace std; #define LL long long int a[100]; int main() {
a[1]=114514; a[2]=1919810; FILE* fp = fopen("1.bin","wb"); fwrite(a,4,100,fp); fclose(fp); fp = fopen("1.bin","rb"); fread(a,4,100,fp); fclose(fp); cout<<a[1]<<" "<<a[2]<<'\n';
return 0; }
|
于是,我们可以利用 fwrite
,一次写入 1GB,让你的硬盘原地爆炸
1 2 3 4 5 6 7 8 9 10
| #include<bits/stdc++.h> using namespace std; #define LL long long int a[1<<28]; int main() { FILE* fp = fopen("boom","wb"); while(1) fwrite(a,sizeof a,1,fp); fclose(fp); return 0; }
|