文件读写与重定向

 1 #include<iostream>
 2 #include<fstream>
 3 #include<cstdio>
 4 #include<string.h>
 5 #include<cstdlib>
 6 using namespace std;
 7 int main()
 8 {
 9     freopen("weblink_new.txt","r",stdin);
10     freopen("new.txt","w",stdout);
11 
12     int i,j,k;
13     char str[2000];
14     while(gets(str))
15     {
16         int len = strlen(str);
17         if(len == 0)
18             strcpy(str,"NA");
19        cout<<str<<endl;
20     }
21 
22     fclose(stdin);
23     fclose(stdout);
24 
25     return 0;
26 }

 

posted @ 2012-12-20 16:37  huj690  阅读(255)  评论(0编辑  收藏  举报