linux gcc时出现读写文件的error

irisflowers 2012-03-22 06:52:17
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);
...全文
102 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
翔云123456 2012-03-23
  • 打赏
  • 举报
回复
不是标点问题

如4楼所说

是 函数语句没写对地方
翔云123456 2012-03-23
  • 打赏
  • 举报
回复
是不是标点符号的问题的呢,使用英文下的标点
justkk 2012-03-23
  • 打赏
  • 举报
回复
这两行应该放在函数体内
freopen("sample_data.in","r",stdin);
freopen("sample_data.out","w",stdout);
irisflowers 2012-03-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 justkk 的回复:]

程序的前20行贴一下看看
[/Quote]
#include<stdio.h>
#include<pthread.h>
#include<sys/types.h>
#include<unistd.h>

/*----declaring and initilazing matrices----*/
#define M 5000
int A[M][M];
int B[M][M];
int C[M][M];
int z=0;
int N;

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

/*------struct defination-----*/
struct v
{
int r; //row
int c; //column

};
justkk 2012-03-22
  • 打赏
  • 举报
回复
程序的前20行贴一下看看

23,121

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧