array program

This is a discussion on array program within the C Programming forums, part of the General Programming Boards category; where are these errors Code: #include<stdio.h> int comparason_function(int x1, int x2) { if(x1==x2) return 0; else if(x1!=x2) return -1; return ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    19

    array program

    where are these errors

    Name:  error2.jpg
Views: 300
Size:  32.2 KB

    Code:
    #include<stdio.h>
    
    
    
    
    int
    comparason_function(int x1, int x2)
    {
        if(x1==x2)
             return 0; 
        else if(x1!=x2)
            return -1; 
         return 0;
    }
    
    
    int main()
    {
        FILE* file;
        char* filename;
        int ii;
        int jj;
        
        int array1[25];
         int array2[25];
        
        filename = "data2.txt";
        file = fopen (filename, "r");
        
        printf("THIS PROGRAM IS DONE BY REZA MOLOUDI. ALL RIGHTS ARE RESEVED\n");
         
        
       
        for (jj=0; jj<25 ; jj++)
        {
            fscanf (file, "%d", &array1[jj]);
            //a[j] = i;
        }
        
         
        
        for (jj=0; jj<25 ; jj++)
        {
            fscanf (file, "%d", &array2[jj]);
        }
        
       
        
        for(ii=0 ; ii<25 ; ii++)
         {
            if (comparason_function(array1[ii],array2[ii])==0)
                printf("A %d is found in Cell #%d \n", array1[ii], ii);
        }
        
        
         return 0;
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,688
    Remove the // comment.

    // comments don't appear in C until C99.

    You're using -std=iso9899:199409
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    2,597
    Try applying the advice given in post #4 of your previous post. Let us know if that fixes it.

  4. #4
    Registered User
    Join Date
    Oct 2012
    Posts
    19
    well i removed all comments. right now i have only these two errors

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with array program.
    By Brian29 in forum C Programming
    Replies: 4
    Last Post: 10-21-2012, 02:50 PM
  2. Need help with a array program
    By antim in forum C Programming
    Replies: 2
    Last Post: 03-06-2011, 12:16 PM
  3. Replies: 1
    Last Post: 03-16-2010, 10:17 AM
  4. Help converting array program to link list program
    By hsmith1976 in forum C++ Programming
    Replies: 0
    Last Post: 02-14-2010, 08:50 PM
  5. Help with Array Program!
    By ProgrammingDlux in forum C++ Programming
    Replies: 2
    Last Post: 03-14-2002, 12:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21