*p is a pointer to struct temp.
It would be having a memory address wherever it is located.
incrementing p gives out of memory bounds.
can we print (or access) the two integers contained in it using pointer?
I mean like the way we can for an integer array.
User Profile
Collapse
Profile Sidebar
Collapse
vrinda yadav
Last Activity: Feb 14 '11, 06:05 PM
Joined: Apr 25 '10
Location: India
-
I did not mean this way..rather I wanted to know what is meant by type checking that is not supported by printf statement..if it can differentiate between whether printing an integer or a character as above..Leave a comment:
-
if printf("%d",*p) ; statement is replaced with printf("%c",*p) ; in the above code
then what would be the change in the output and why..??Leave a comment:
-
proper code:
Code:#include<iostream.h> struct temp { int j; int i; }a; void fun(struct temp *p) { cout<<*p; //error p++; cout<<*p; } void main() { struct temp *z=&a; z->j=10; z->i=1; fun(z); }
output: 10 <garbage>
if used...Leave a comment:
-
What is difference between printf and cout?
What is the difference between the following two statements in a c++ code.?
1. cout<<*p; //error
2. printf("%d",*p) ; //no error
No activity results to display
Show More
Leave a comment: