Thread: array program

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

    array program

    where are these errors

    array program-error2-jpg

    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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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.

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    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, 01: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, 09:50 PM
  5. Help with Array Program!
    By ProgrammingDlux in forum C++ Programming
    Replies: 2
    Last Post: 03-14-2002, 01:02 PM