C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-08-2009, 10:44 AM   #1
Registered User
 
Join Date: Nov 2009
Posts: 2
Exchange pointers

Hi!!

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:
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)??
Lasering is offline   Reply With Quote
Old 11-08-2009, 10:57 AM   #2
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,944
Quote:
Originally Posted by Lasering View Post
Can someone point me to the light (LOOOL)??
With an array you must do this:
Code:
for (i=0; i<15; i++) ray_two[i] = ray_one[i];
Make sense?
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is offline   Reply With Quote
Old 11-08-2009, 11:36 AM   #3
Registered User
 
Join Date: Nov 2009
Posts: 2
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!!.
Lasering is offline   Reply With Quote
Old 11-08-2009, 12:48 PM   #4
Registered User
 
Join Date: Sep 2006
Posts: 2,502
This is the fastest 180 degree turn yet seen, on the forum!

Those are *some* tires you have there Lasering.
Adak is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using pointers to pointers steve1_rm C Programming 18 05-29-2008 05:59 AM
Euclid Algorithm (extended)Part2 Doubt about pointers - INITIALIZATION nacho4d C Programming 4 12-10-2006 07:08 PM
Request for comments Prelude A Brief History of Cprogramming.com 15 01-02-2004 10:33 AM
Staticly Bound Member Function Pointers Polymorphic OOP C++ Programming 29 11-28-2002 01:18 PM


All times are GMT -6. The time now is 07:51 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22