C To MIPS - translate a simple code -


int i; void set_array(int num) {     (i=0; i<10;i++) {         a[i] = compare(num,i);     } }  int compare (int a, int b) {     if ((a-b) >= 0)         return 1;     else return 0 } 

getting problems here.

my major problem is: how can insert compare(num,i) a[i]?

by way, i'm totally beginner in this, sorry if seems easy asked.

in c cannot "insert" values. first, had declare [global] table either

int a[10]; 

assuming 10 size, based on for loop limit, or

int *a; 

then somewhere else in code:

a = malloc (10 * sizeof *a); 

so have space allocated 10 elements. can set w value of each element (like compare() assignment).


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -