Thread: Need Quick Help with 2 Syntax Errors

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    7

    Need Quick Help with 2 Syntax Errors

    Hey guys, I have 2 syntax errors in my code and I can't for the life of me figure them out. I'm not that great at C yet, but I hope to be soon.

    So without further adue:

    program6.c: In function `main':
    program6.c:40: syntax error before ';' token
    Code:
    fprintf(infile,"Average Gain/Loss: $ %f\n",(total/soldcnt));
    for(i=0;i<20;i++;)  /*line40*/
    {if gainary[i]!=0
     std=(gainary[i]-(total/soldcnt))sqr/(i-1);
    }

    program6.c: In function `inputfn':
    program6.c:60: syntax error before '*' token
    Code:
    void inputfn(int idary[], int soldary[], float paidary[], float
    recievedary[],float gainary[], int *soldcnt, int *unsoldcnt)
    float paid, recieved, gain;
    int id, sold, flag, i;
    *soldcnt=0; /*line 60*/
    *unsoldcnt=0;

    Thanks guys! (and girls!)

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    In the first code it looks like you forgot to close your if, also, to fix the error you mentioned take away the ; after i++.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    184
    by looking at your code i have modified some in u'r code
    Code:
    fprintf(infile,"Average Gain/Loss: $ %f\n",(total/soldcnt));
    for(i=0;i<20;i++)  /*line40*/
    {(if gainary[i]!=0)
     std=(gainary[i]-(total/soldcnt))sqr/(i-1);
    }
    with the second code

    Code:
    void inputfn(int idary[], int soldary[], float paidary[], float
    recievedary[],float gainary[], int *soldcnt, int *unsoldcnt){
    float paid, recieved, gain;
    int id, sold, flag, i;
    *soldcnt=0; /*line 60*/
    *unsoldcnt=0;
    thats the only this i can find in your second code which u have posted. and i think rest are all fine

    s.s.harish

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by ssharish
    by looking at your code i have modified some in u'r code
    Code:
    {(if gainary[i]!=0)
    Since when do you put parenthesis around the actual "if"?

    Code:
    if ( grainary[i] != 0 ) 
         ...stuff...
    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    184
    ohh you teach me to be more perfect Quazah

    thax very much for that

  6. #6
    The C-er
    Join Date
    Mar 2004
    Posts
    192
    std=(gainary[i]-(total/soldcnt))sqr/(i-1);
    This is all wrong. what is sqr? is it a variable or a function?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changed Program, Now Getting Syntax Errors
    By DonFord81 in forum C Programming
    Replies: 11
    Last Post: 03-05-2009, 10:13 AM
  2. 3x syntax errors :S, Help a student finalise an assignment
    By Chickenhawk in forum C Programming
    Replies: 14
    Last Post: 07-27-2006, 05:14 AM
  3. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  4. quick hex question
    By shoobsie in forum C Programming
    Replies: 3
    Last Post: 06-29-2005, 08:36 AM
  5. header file bringing errors?
    By bluehead in forum Windows Programming
    Replies: 4
    Last Post: 08-19-2003, 12:51 PM