为什么会error: syntax error at end of input???

清风伴月88 2006-12-18 09:44:09
编译提示如下错误: 没有语法错误啊,请问是为什么?
clone.c: In function `main':
clone.c:55: error: syntax error at end of input

#include <stdlib.h>
#include "semaphore.h"
#include "pthread.h"
int reader_function(int);
int writer_function(int);
char buffer[100];
sem_t product;
sem_t s;
pthread_mutex_t mutex;
main(){
pthread_t reader,writer;
pthread_mutex_init(&mutex,NULL);
char *stack;
int clone_flag,id,retval;
clone_flag=CLONE_VM|CLONE_SIGHAND|CLONE_FS|CLONE_FILES;
int i;
for(i=1;i<=2;i++){
id=i;
stack=(char *)malloc(4096);
retval=clone((void *)writer_function,&(stack[4095]),clone_flag,&id);
stack=(char *)malloc(4096);
retval=clone((void *)reader_function,&(stack[4095]),clone_flag,&id);
}
exit(1);
int write_function(id){
sem_wait(&s);
pthread_mutex_lock(&mutex);
if(id==1){
printf("write function1 is running!\n");
sprintf(buffer,"aaa\n",100); }
else{
printf("write function2 is runing!\n");
sprintf(buffer,"bbb\n",100);
} pthread_mutex_unlock(&mutex);
sem_post(&s);
} int read_function(id){
sem_wait(&product);
pthread_mutex_lock(&mutex);
if(id==1){
printf("buffer was read by reader 1!\n");
printf("%s\n",buffer);
} else {
printf("buffer was read by reader 2!\n");
printf("%s\n",buffer);
} pthread_mutex_unlock(&mutex);
sem_post(&product);
}

...全文
3356 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
loveisbug 2006-12-19
  • 打赏
  • 举报
回复
底下又多出一个括号
x86 2006-12-19
  • 打赏
  • 举报
回复
很明显最后少一个大括号。看看是否这个问题。

23,120

社区成员

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

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