Thread: Exchange pointers

  1. #1
    Registered User
    Join Date
    Nov 2009

    Exchange pointers


    I have a type queue_t, its a head of a linked list. Then I have these variables:

    queue_t *exe_thr_list[15];
    queue_t *expired_thr_list[15];

    They are arrays of 15 elements, where each element is a pointer to queue_t (Pretty obvious).

    So far so good. Now I want to make a function to swich them. What I mean is:

    what ever exe_thr_list points to must (after the function is called) point to whaever expired_thr_list points to. And vice versa. In other words to swich the two arrays.

    I made this obviously wrong code:
    queue_t *tmp_queue[15];
    tmp_queue = exe_thr_list;
    exe_thr_list = expired_thr_list;
    expired_thr_list = tmp_queue;
    Wrong because I can't compile it with gcc, getting the following error:

    error: incompatible types in assignment

    in the last three lines of code.

    Can someone point me to the light (LOOOL)??

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    segmentation fault
    Quote Originally Posted by Lasering View Post
    Can someone point me to the light (LOOOL)??
    With an array you must do this:
    for (i=0; i<15; i++) ray_two[i] = ray_one[i];
    Make sense?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Nov 2009
    Actually not. Because its like take you are putting the values of array one in array two, but now putting the values os array two in one.

    Anyway I think I can resolve my problem with that code.

    Thks a lot!!.

  4. #4
    Registered User
    Join Date
    Sep 2006
    This is the fastest 180 degree turn yet seen, on the forum!

    Those are *some* tires you have there Lasering.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. Replies: 4
    Last Post: 12-10-2006, 07:08 PM
  3. Request for comments
    By Prelude in forum A Brief History of
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM