新手,求大神指教freopen重定向的输入方式
一个简单小程序求指导输入在哪里,不知道如何输入
#include
int main()
{
freopen("tase.in", "r", stdin);
int x;
scanf("%d\n", &x);
printf("%d\n", x);
return 0;
}
2014-03-02 11:19
2014-03-02 11:41
程序代码:#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
int a, b;
freopen("in.txt" , "r", stdin); //输入流重定向到 文件 in.out,即在 in.out 中读取
freopen("out.txt", "w", stdout);//输出流重定向到 文件 out.txt,即记过写入 out.txt
scanf("%d%d", &a, &b);
printf("%d\n", a + b);
fclose(stdin); //关闭输入流
fclose(stdout); //关闭输出流
return 0;
}
/**
* in.txt内容
* 2 3
*
* 执行后 out.txt 内容
* 5
**/

2014-03-02 14:12
2014-03-02 14:20
2014-03-04 09:24
2014-03-04 09:24
2014-03-04 18:37

2014-03-04 19:35
2014-03-11 09:48