#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    I cant find my parse error


    [highlight]i can't run my program because o a supposed parse error... please do help me :(

    int UpdateSong(SongInf *list, int *get, int count, int countGet)
    {
    int n;
    SongInf temp;
    char rating[10];
    char answer;
    FILE *input;
    while(1)
    {
    printf("\n\nWhich entry do you want to edit?"
    "\nEnter number 0 to go back to main menu");
    scanf("%d",&n);
    getchar();
    if(n == 0)
    {
    return 0;
    }
    else if(n <= countGet)
    {
    printf("\nSONG INFO");
    printf("\nTitle: " ,list[get[n-1]].Title);
    printf("\nArtist: " ,list[get[n-1]].Artist);
    printf("\nGenre: " ,list[get[n-1]].Genre);
    printf("\nAlbum: " ,list[get[n-1]].Album);
    printf("\nRating: " ,list[get[n-1]].Rating);
    printf("\nRemarks: " ,list[get[n-1]].Remarks);
    }
    else
    {
    printf("Invalid input. Enter answer again \n");
    }
    }

    do
    {
    printf("\n\nEDIT"
    "\nEnter to skip field"
    "\nType exit to go back to main menu"
    "\nTitle: ");
    if(strcmp(gets(temp.Title),"exit")==0)
    {
    free(get);
    free(list);
    return 0;
    }
    printf("\nArtist: ");
    if(strcmp(gets(temp.Artist),"exit")==0)
    {
    free(get);
    free(list);
    return 0;
    }
    printf("\nGenre: ");
    if(strcmp(gets(temp.Genre),"exit")==0)
    {
    free(get);
    free(list);
    return 0;
    }
    printf("\nAlbum: ");
    if(strcmp(gets(temp.Album),"exit")==0)
    {
    free(get);
    free(list);
    return 0;
    }
    printf("\nRating: ");
    if(strcmp(gets(rating),"exit")==0)
    {
    free(get);
    free(list);
    return 0;
    }
    printf("\nRemarks: ");
    if(strcmp(gets(temp.Remarks),"exit")==0)
    {
    free(get);
    free(list);
    return 0;
    }
    if(*temp.Title != '\0')
    {
    strcpy(list[get[n-1]].Title,temp.Title);
    }
    if(*temp.Artist != '\0')
    {
    strcpy(list[get[n-1]].Artist,temp.Artist);
    }
    if(*temp.Genre != '\0')
    {
    strcpy(list[get[n-1]].Genre,temp.Genre);
    }
    if(*temp.Album != '\0')
    {
    strcpy(list[get[n-1]].Album,temp.Album);
    }
    if(*rating != '\0')
    {
    temp.Rating = atoi(rating);
    list[get[n-1]].Rating = temp.Rating;
    }
    if(*temp.Remarks!= '\0')
    {
    strcpy(list[get[n-1]].Remarks,temp.Remarks);
    }
    printf("\nNEW SONG INFO");
    printf("\nTitle: %s ",list[get[n-1]].Title);
    printf("\nArtist: %s",list[get[n-1]].Artist);
    printf("\nGenre: %s",list[get[n-1]].Genre);
    printf("\nAlbum: %s",list[get[n-1]].Album);
    printf("\nRating: %d",list[get[n-1]].Rating);
    printf("\nRemarks: %s",list[get[n-1]].Remarks);

    while(1)
    {
    printf("\nDo you want to save these changes? (Y)es or (N)o? ");
    scanf("%c",&answer);
    getchar();
    if(answer == 'Y')
    {
    input = fopen("MProb.txt","wb");
    if(fwrite(list,sizeof(SongInf),count,input) != (unsigned)count)
    {
    printf("\nError in updating song"
    "\nPress any key to go back to main menu");
    getchar();
    fclose(input);
    break;
    }
    printf("\nUpdating complete!"
    "\nPress any key to go back to main menu");
    getchar();
    fclose(input);
    break;
    }
    if(answer == 'N')
    {
    break;
    }
    else
    {
    printf("\nInvalid input. Input again!\n");
    }

    free(get);
    free(list);
    return 0;
    }
    }
    }
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    156
    Rep Power
    34
    Your code would be easier to check if it were inside the code tags.
    When you write code, write it between [ code ] and [ /code ] (without the spaces).

    check for absence of semicolons.
    check for mismatched or missing quotes or apostrophes.
    check for matching of braces, and parenthesis.
    check for dangling elses.
  4. #3
  5. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,162
    Rep Power
    2222
    And if you're getting a compiler warning or error message, don't make us play a guessing game with you. Just tell us what the compiler told you. Preferably by copy-and-pasting it.
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,854
    Rep Power
    481
    Assuming
    Code:
    SongInf {
      char*Title,*Artist,*Genre,*Album,*Remarks;
      int Rating
    };
    You have a bunch of printf statements

    printf("\nTitle: " ,list[get[n-1]].Title);

    where you probably should have

    printf("\nTitle: %s\n" ,list[get[n-1]].Title);

    In other words, the format specifier tells where to put the arguments and how to interpret them.



    I suppose the big problem confronting you is that you have a "do" statement without a matching "while" .

    http://msdn.microsoft.com/en-us/library/8z1ch5dd(v=vs.80).aspx
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo