|
INTERVIEW QUESTIONS
C
OPERATORS IN C
DETAILS
Question: Can math operations be performed on a void pointer?
Answer: No. Pointer addition and subtraction are based on advancing the pointer by a number of elements. By definition, if you have a void pointer, you don’t know what it’s pointing to, so you don’t know the size of what it’s pointing to. If you want pointer arithmetic to work on raw addresses, use character pointers.
|
|
|
Category |
Operators in C Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 8754 users |
Added on |
10/22/2009 |
Views |
84113 |
Rate it! |
|
|
Question:
Can math operations be performed on a void pointer?
Answer:
No. Pointer addition and subtraction are based on advancing the pointer by a number of elements. By definition, if you have a void pointer, you don’t know what it’s pointing to, so you don’t know the size of what it’s pointing to. If you want pointer arithmetic to work on raw addresses, use character pointers. Source: CoolInterview.com
Hi... Yes....Math operations can be performed on void pointers.. But you must do type casting for that purpose... The syntax is: op (data_type *)ptr_name; In above syntax op is the unary opetator... Source: CoolInterview.com
Answered by: Ashwini.........ACPCE | Date: 4/6/2010
| Contact Ashwini.........ACPCE
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What is a modulus operator? What are the restrictions of a modulus operator?
|
View Answer
|
|
Why n++ executes faster than n+1?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Operators in C Interview Questions & Answers - Exam Mode /
Learning Mode
|