Esempio n. 1
0
int main() {
  int a = 1, b = 2;
  swap(&a, &b);
  printf("a = %d, b = %d\n", a, b);

  char* s1 = "aaa"; // stored in a read-only area
  char* s2 = "bbb"; // stored in a read-only area
  swap_string(&s1, &s2);
  printf("s1 = %s, s2 = %s\n", s1, s2);

  return 0;
}
Esempio n. 2
0
void
mix_colors(void)
{
    short i, j;
    char *t;
    extern char *po_color[];

    for (i = 0; i < POTIONS; i++) {
	strcpy(id_potions[i].title, po_color[i]);	/* by Yahsa */
/*		id_potions[i].title = po_color[i];*/
    }
    for (i = 0; i < POTIONS; i++) {
	j = get_rand(i, POTIONS - 1);
	swap_string(id_potions[i].title, id_potions[j].title);
    }
}
Esempio n. 3
0
  void get_rank_list(char *string [ ],
                 int array [ ] [SUBJECTS + 1],
                 int m,
                 int n)
   {
     int i, j, k, (*rowptr)[SUBJECTS+1] = array;
     char *temp;

     for(i = 1; i <= m-1; i++)
        for(j = 1; j <= m-i; j++)
           if( (*(rowptr + j-1))[n-1] < (*(rowptr + j))[n-1])
           {
            swap_string(string[j-1], string[j]);

            for(k = 0; k < n; k++)
            swap_int(&(*(rowptr + j-1))[k],&(*(rowptr+j))[k]);
             }
   }