当前位置: 技术问答>linux和unix
linux gcc时出现读写文件的error
来源: 互联网 发布时间:2017-02-11
本文导语: 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: warni...
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);
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);
freopen("sample_data.in","r",stdin);
freopen("sample_data.out","w",stdout);