首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

linux gcc时出现读写文件的error解决办法

2012-04-01 
linux gcc时出现读写文件的errorm.c:14: error: expected declaration specifiers or ‘...’ before string

linux gcc时出现读写文件的error
m.c:14: error: expected declaration specifiers or ‘...’ before string constant
m.c:14: error: expected declaration specifiers or ‘...’ before string constant
m.c:14: error: expected declaration specifiers or ‘...’ before ‘stdin’
m.c:14: warning: data definition has no type or storage class
m.c:14: error: conflicting types for ‘freopen’
/usr/include/stdio.h:255: note: previous declaration of ‘freopen’ was here
m.c:15: error: expected declaration specifiers or ‘...’ before string constant
m.c:15: error: expected declaration specifiers or ‘...’ before string constant
m.c:15: error: expected declaration specifiers or ‘...’ before ‘stdout’
m.c:15: warning: data definition has no type or storage class
m.c:15: error: conflicting types for ‘freopen’
/usr/include/stdio.h:255: note: previous declaration of ‘freopen’ was here

我的14,15行是

freopen("sample_data.in","r",stdin);
freopen("sample_data.out","w",stdout);


[解决办法]
这两行应该放在函数体内
freopen("sample_data.in","r",stdin);
freopen("sample_data.out","w",stdout);

热点排行