GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 29-Oct-2009, 05:45
nilusha6 nilusha6 is offline
New Member
 
Join Date: Aug 2008
Posts: 12
nilusha6 is an unknown quantity at this point

How to convert a variable to a double pointer


I have a variable in header file something like,

CPP / C++ / C Code:
typedef struct aa{
.....
type_of_variable **p_variable;
...
}aa;

Then i want to cast some other variable to, that pointer.
im getting that structer as a pointer variable in my function parameters.

CPP / C++ / C Code:
func_1 (aa *p_aa)
{
type_bb variable_2;

//I want to convert this variable_2 to type_of_variable
//Is the following line correct?????

aa->p_variable = (type_of_variable **) variable_2;
}
Last edited by admin : 29-Oct-2009 at 06:07. Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
  #2  
Old 29-Oct-2009, 08:33
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: How to convert a variable to a double pointer


Quote:
Originally Posted by nilusha6
...Is the following line correct?

1. What do you expect to happen when you try it?

2. What happens when you try it?

If (Result(1) == Result(2)) then it is correct, else it is not correct.

In other words: You can write a program that does what you say. Whether it is "correct" depends on what you are trying to accomplish. See Footnote.


Regards,

Dave


Alice: "Which way shall I go?"

Cheshire Cat: "Where do you want to go?"

Alice: "It really doesn't matter."

Cheshire Cat: "Then it doesn't matter which way you go."

---Lewis Carroll
Alice's Adventures in Wonderland
Last edited by davekw7x : 29-Oct-2009 at 09:14.
  #3  
Old 29-Oct-2009, 09:08
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 802
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: How to convert a variable to a double pointer


Looks like it might should be:
CPP / C++ / C Code:
p_aa->p_variable = (type_of_variable **) variable_2;
but whether it's right or not depends on exaclty what "type_bb" and "type_of_variable" are.
Why don't you make a minimal working example of exactly what you are trying to do and post that.
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Powell Method EngineerFORhire C Programming Language 5 01-Oct-2005 01:34
[Tutorial] Pointers in C (Part II) Stack Overflow C Programming Language 0 27-Apr-2005 18:36
[Tutorial] Pointers in C (Part I) Stack Overflow C Programming Language 1 08-Apr-2005 19:35
Double output leanieleanz C++ Forum 1 11-Mar-2005 21:19

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:12.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.