LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 4251|回复: 42

错误提示:parse error at end of input

[复制链接]
发表于 2002-11-25 00:20:48 | 显示全部楼层 |阅读模式
这个错误提示 出现在
111 行 但是我的程序 只有 100 行呀 !
一般会是什么错误  ?
发表于 2002-11-25 10:33:33 | 显示全部楼层
出现这种错误一般是标点符号造成的。以后发贴要讲清楚你编程的软硬环境,如你用的是什么编辑器?用gcc还是其它编译器来编译程序?必要时要贴出源代码。
 楼主| 发表于 2002-11-25 12:06:16 | 显示全部楼层
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>
#include<stdio.h>
struct proc{
  char name[2];
  int  num;
  struct proc *next;
};
int n;
struct proc *head, *this, *new, *current, *temp;
void new_record(void);
void sortlist(void);
void excutable(void);
pid_t pid;
main ()
{
  int i, j;
  for(i=0; i<=8; i++){
    new_record();
  }
  sortlist();
  excutable();
  for(j=1; j<=7; j++){
    current = head;
    excutable();
    if(n>2){
      do{
        this->num = this->num+1;
        if(this->num > 32){
          this->num = this->num%32;
          sortlist();
        }
        this = this->next;
      }while(this->next = NULL);
  }
    free(new);
}
void new_record(void)
{
  int i;
  new = (struct proc *)malloc(sizeof (struct proc));
  if(head == NULL)
    head = new;
  else{
    this = head;
    while(this->next!=NULL)
      this = this->next;
    this->next = new;
  }
  this = new;
  printf("\enter name:");
  scanf("%s",this->name);
  printf("\enter num:");
  this->num = i;
  printf("\n new over");
  this->next = NULL;
}
void sortlist(void)
{
  int i,j;
  this = head;
  for(i=1; i<=8; i++)
    for(j=i+1; j<=8; j++){
      if(this->num < this->next->num){
        temp = this;
        this = this->next;
        this->next = temp;
      }
      this = this->next;
    }
}
void excutable(void)
{
  n = random()%4;
  current = head;
  pid=fork();
  if ( pid>0 ){
    sleep(n);
  }
}
 楼主| 发表于 2002-11-25 12:07:44 | 显示全部楼层
emacs ,gcc  xia tiao  shi
发表于 2002-11-25 15:32:35 | 显示全部楼层

这是修改后编译通过的代码,修改处已作注:

#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>
#include<stdio.h>

struct proc{
        char name[2];
        int num;
        struct proc *next;
};

int n;
struct proc *head, *this, *new, *current, *temp;
       
void new_record(void);
void sortlist(void);
void excutable(void);

pid_t pid;

main ()
{
        int i, j;
        for(i=0; i<=8; i++){
                new_record();
        }
        sortlist();
        excutable();
        for(j=1; j<=7; j++){
                current = head;
                excutable();
                if(n>2){
                        do{
                                this->num = this->num+1;
                                if(this->num > 32){
                                        this->num = this->num%32;
                                        sortlist();
                                }
                                this = this->next;
                        }while(this->next = NULL);
                }
                free(new);
        }
}                        //lost a '}'
       
       
void new_record(void)
{
        int i;
        new = (struct proc *)malloc(sizeof (struct proc));
        if(head == NULL)
                head = new;
        else{
                this = head;
                while(this->next!=NULL)
                        this = this->next;
                this->next = new;
        }
        this = new;
        printf("\nenter name:");                //what did u mean of '\e'??
        scanf("%s",this->name);
        printf("\nenter num:");                        //what did u mean of '\e'??
        this->num = i;
        printf("\n new over");
        this->next = NULL;
}

void sortlist(void)
{
        int i,j;
        this = head;
        for(i=1; i<=8; i++)
                for(j=i+1; j<=8; j++){
                        if(this->num < this->next->num){
                        temp = this;
                        this = this->next;
                        this->next = temp;
                        }
                this = this->next;
                }
}

void excutable(void)
{
        n = random()%4;
        current = head;
        pid=fork();
        if ( pid>0 ){
                sleep(n);
        }
}
发表于 2002-11-25 15:36:18 | 显示全部楼层

晕~~ 非得要html不成?

呵呵,所有的tab全部显示不了~~~

你在44行少了个右括号!!在60,62行的printf()语句中的'\e'是什么意思?

提示的意思是,在输出结束前,有表达错误!
发表于 2002-11-25 15:37:39 | 显示全部楼层

还有就是:

你怎么可以拿this和new做变量名呢?!!

有点可读性和兼容性行不行?!!
 楼主| 发表于 2002-11-25 18:33:55 | 显示全部楼层
parse error at end of input

我说了 这是 c 语言 可以使用 this
关键是 parse error at end of input   这句话的错误 其他错误已经改了 而且提示 是 111 行 可程序 只有 100 喊 !
发表于 2002-11-25 19:57:45 | 显示全部楼层
top123:
写程序要注意不要使用c/c++中的关键字,要有可读性,否则,除了你,任何人都不会看懂这段代码,帮助你就更别提了。
 楼主| 发表于 2002-11-25 20:24:23 | 显示全部楼层
我知道了 ! 但是 在c 里面this new 不是关键字呀
只有在 c++ 才识
请你调试一下 运行看看 !
谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表