Skip to Main Content
Data Structures Using C, 2nd Edition by Pearson
book

Data Structures Using C, 2nd Edition by Pearson

by A. K. Sharma
May 2024
Intermediate to advanced content levelIntermediate to advanced
521 pages
14h 12m
English
Pearson India
Content preview from Data Structures Using C, 2nd Edition by Pearson
210 Data Structures Using C
/* Print data through arrow operator */
printf (“\n The data for the item...”);
printf (“\nCode : %s”, ptr −> code);
printf (“\nQty : %d”, ptr −> Qty);
printf (“\nCost : %5.2f”, ptr −> cost);
}
From the above program, we can see that the members of a static structure can be accessed by both
dot and arrow operators. However, dot operator is used for simple variable whereas the arrow operator
is used for pointer variables.
Example 5: What is the output of the following program?
#include <stdio.h>
main()
{
struct point
{
int x, y;
} polygon[]= {{1,2},{1,4},{2,4},{2,2}};
struct point *ptr;
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

Data Structures Using C

Data Structures Using C

Samir Kumar Bandyopadhyay, Kashi Nath Dey
Intermediate C Programming, 2nd Edition

Intermediate C Programming, 2nd Edition

Yung-Hsiang Lu, George K. Thiruvathukal

Publisher Resources

ISBN: 9781299831582