where should i save my data2.txt file so Xcode can open it.
i dont know why Xcode tells me the program is fine but in quincy 2005 i get errors
this program has to get 50 integers numbers and then put in two arrays and each array 25 integer and then compare the two arrays
Code:#include<stdio.h> /* This function returns 0 (TRUE) when two integers are equal and it returns -1 (FALSE) when they are not equal*/ int comparason_function(int x1, int x2) { if(x1==x2) return 0; // RETURN TRUE else if(x1!=x2) return -1; // RETURN FALSE 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"); /* SAVE ALL the first 25 integers in array1*/ for (jj=0; jj<25 ; jj++) { fscanf (file, "%d", &array1[jj]); //a[j] = i; } /* SAVE ALL THE SECOND 25 INTEGERS IN array2*/ for (jj=0; jj<25 ; jj++) { fscanf (file, "%d", &array2[jj]); } /* BY CALLING THE comparision_function we figure out which intergers at which places are equal*/ 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; }



LinkBack URL
About LinkBacks



