预期的表达式错误与%

时间:2014-02-26 01:52:47

标签: c

我正在努力让我的代码进行编译以查看它是否按计划运行,但我一直收到错误

  

c:44:错误:在“令牌

之前的预期表达式

我的代码在

下面
int main(int argc, char* argv[])
{
    if (argc<1)
    {
      printf("Incorrect number of arguements\n");
      return 0;
    }

    Player* head = NULL;
    Player* node = NULL;
    char name[NAME_LENGTH], champion[CHAMP_LENGTH], team[TEAM_LENGTH];
    char temp;
    int kills, deaths = 0;
    FILE *in = fopen(argv[1], "r");

    while (1)
    {               /*error is here*/
      fscanf(in, "%s%c%s%c%s%c%d%c%d%c", name, &temp, champion, %temp, team, &temp, &kills, &temp, &deaths, &temp); 
      if (feof(in)) break;

      node = new_player(name, champion, team, kills, deaths);
      head = insert_by_player(head, node);

    }
return 0;
}

1 个答案:

答案 0 :(得分:1)

%temp的参数列表中有&temp而不是fscanf

但请注意,您可以写:

fscanf("%d%*c%d", &a, &b);

"%*c"表示读取但忽略了一个字符,因此您根本不需要虚拟&temp