Previous in Forum: Solar and Wind Systems   Next in Forum: Web Page Development for Office Use
Close
Close
Close
12 comments
Rate Comments: Nested
Anonymous Poster

Void Pointer

02/06/2008 4:06 AM

whats different between void *p and void q;

Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Guru
United Kingdom - Member - Indeterminate Engineering Fields - Control Engineering - New Member

Join Date: Jan 2007
Location: In the bothy, 7 chains down the line from Dodman's Lane level crossing, in the nation formerly known as Great Britain. Kettle's on.
Posts: 32175
Good Answers: 839
#1

Re: void pointer

02/06/2008 4:22 AM

In what context?

__________________
"Did you get my e-mail?" - "The biggest problem in communication is the illusion that it has taken place" - George Bernard Shaw, 1856
Reply
Power-User
United Kingdom - Member - Member

Join Date: Mar 2007
Location: Blackburn, Lancashire
Posts: 269
Good Answers: 9
#2

Re: void pointer

02/06/2008 4:24 AM

Its been some time since I did any C programming but as I remember void *p declares a void pointer which can be used to point to the address of any other type of variable with appropriate casting. void q would declare a variable of the type void but as void is used to indicate that no variable is to be passed to/from a function then I doubt this would be a legal declaration and I can't think of any purpose for doing it.

I could be wrong on the second point

Al

__________________
If you remain calm while all those around you are losing their heads, then you haven't realised the seriousness of the situation
Reply Score 1 for Good Answer
Guru
Engineering Fields - Instrumentation Engineering - New Member Hobbies - Fishing - New Member

Join Date: Jan 2008
Location: Kazakhstan
Posts: 753
Good Answers: 8
#3

Re: void pointer

02/06/2008 6:44 AM

It seems it's homework.

Incorrectly formulated question in any case.

(1) You have forgotten a brackets ( ).

(2) you should use either p, *p or q, *q. Otherwise every one can say you that p looks different of q.

Owing to (1) what's a point to find difference when both notations are wrong initially?

Study a textbook.

Reply
Power-User
United Kingdom - Member - Member

Join Date: Mar 2007
Location: Blackburn, Lancashire
Posts: 269
Good Answers: 9
#4
In reply to #3

Re: void pointer

02/06/2008 6:57 AM

(1) You have forgotten a brackets ( ).

Brackets are not required when declaring a variable or a pointer. You seem to be suggesting that p or q is a function name

__________________
If you remain calm while all those around you are losing their heads, then you haven't realised the seriousness of the situation
Reply
Guru
Engineering Fields - Instrumentation Engineering - New Member Hobbies - Fishing - New Member

Join Date: Jan 2008
Location: Kazakhstan
Posts: 753
Good Answers: 8
#5
In reply to #4

Re: void pointer

02/06/2008 7:15 AM

Hello Botton Alan!

VOID can declare only function with nothing to return. So brackets are needed there in any case for getting meaningful C statement and therefore question.

Other way it's nonsense at all. Are we discuss about C?

Try to declare variable this way void q; and look at compiler response.

Seems ours guest had got all tips for his/her question .

Reply
Power-User
United Kingdom - Member - Member

Join Date: Mar 2007
Location: Blackburn, Lancashire
Posts: 269
Good Answers: 9
#6
In reply to #5

Re: void pointer

02/06/2008 8:06 AM

Caramba,

I no longer program in C or C++ but I distinctly remember declaring a pointer as type void

i.e. void *p

in order to pointer and access varying data types in a recordset returned by a sql database. Now that particular project was in C++ so maybe it was just a C++ thing

Al

__________________
If you remain calm while all those around you are losing their heads, then you haven't realised the seriousness of the situation
Reply
Guru
Engineering Fields - Instrumentation Engineering - New Member Hobbies - Fishing - New Member

Join Date: Jan 2008
Location: Kazakhstan
Posts: 753
Good Answers: 8
#7
In reply to #6

Re: void pointer

02/06/2008 8:10 AM

Al,

You're right void *p will be passed by compiler I didn't write that it can't. Yes it may be cast any kind of integer or char variable at its address, though I use never this trick.

But I emphasize that we have here incorrect question.

All my kind regards and respect to you.

Reply
Power-User
United Kingdom - Member - Member

Join Date: Mar 2007
Location: Blackburn, Lancashire
Posts: 269
Good Answers: 9
#8
In reply to #7

Re: void pointer

02/06/2008 8:42 AM

You stated:

VOID can declare only function with nothing to return

This is not true, as void can also be used to declare a void pointer. The fact that your compilere allows you to do that but not declare a variable of type void confirms both parts of my first post (feel free to rate it as a good answer).

Thanks for the feed back about your compiler

regards

Al

__________________
If you remain calm while all those around you are losing their heads, then you haven't realised the seriousness of the situation
Reply
Guru
Engineering Fields - Instrumentation Engineering - New Member Hobbies - Fishing - New Member

Join Date: Jan 2008
Location: Kazakhstan
Posts: 753
Good Answers: 8
#9
In reply to #8

Re: void pointer

02/06/2008 8:49 AM

Ok, ok you won

Reply Off Topic (Score 3)
Guru
United Kingdom - Member - Olde Member!! Engineering Fields - Instrumentation Engineering - New Member

Join Date: Jul 2006
Location: Dunstable, England
Posts: 2821
Good Answers: 45
#10
In reply to #9

Re: void pointer

02/06/2008 9:46 AM

WTF is a void pointer????

This discussion all seems a bit empty to me

__________________
A little knowledge is a dangerous thing - Googling is far worse!
Reply Off Topic (Score 3)
Power-User
United Kingdom - Member - Member

Join Date: Mar 2007
Location: Blackburn, Lancashire
Posts: 269
Good Answers: 9
#11
In reply to #10

Re: void pointer

02/06/2008 9:51 AM

Electro,

A void pointer is a pointer capable of pointing to any area of memory occupied by a variable of any type as long as it is cast to that type when assigning it an address

Clear as mud?

Al

__________________
If you remain calm while all those around you are losing their heads, then you haven't realised the seriousness of the situation
Reply
Guru
Engineering Fields - Instrumentation Engineering - New Member Hobbies - Fishing - New Member

Join Date: Jan 2008
Location: Kazakhstan
Posts: 753
Good Answers: 8
#12
In reply to #10

Re: void pointer

02/06/2008 9:58 AM

Hi,Electroman,

Very good said!

Reply Off Topic (Score 5)
Reply to Forum Thread 12 comments

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Copy to Clipboard

Users who posted comments:

Bolton_Alan (5); caramba (5); Electroman (1); PWSlack (1)

Previous in Forum: Solar and Wind Systems   Next in Forum: Web Page Development for Office Use
You might be interested in: Protective Packaging, Pressure Gauges, Control Knobs

Advertisement