Skip to Main Content
Programming and Data Structures
book

Programming and Data Structures

by Ashok Kamthane
August 2009
Intermediate to advanced content levelIntermediate to advanced
604 pages
21h 39m
English
Pearson India
Content preview from Programming and Data Structures
Pointers 313
{
c lrs c r ( );
*(int *)p t = 12;
printf ("\np= %d”,p);;
%
II
1* pt points to d */
*(float *)pt = 5.4;
printf ( “\nr=%f',d);
pt=&c; 1* pt points to c V
*(char* )pt='S';
printf ("\nc= %c",c);
}
OUTPUT
P=12
R=5.4
O S
Explanation In the above example variable p, d and c are variable of type in t , f l o a t and char
respectively. Pointer p t is a pointer of type void. All these variables are declared before main ( ) . The
pointer is initialized with the address of integer variable p i.e. the pointer p points to variable x.
The statement *(int *) pt = 12 assigns the integer value 12 to pointer p t i.e to variable p. The contents
of variable p
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Data Structures and Algorithms

Learning Data Structures and Algorithms

Rod Stephens
Data Structures and Algorithms in C++, Second Edition

Data Structures and Algorithms in C++, Second Edition

Michael T. Goodrich, Roberto Tamassia, David M. Mount

Publisher Resources

ISBN: 9789332506343