0
#include<stdio.h>

	struct rec
	{
    		int i;
    		float PI;
    		char A;
	};

	int main()
	{
		struct rec *ptr_one;
		ptr_one =(struct rec *) malloc (sizeof(struct rec));

		ptr_one->i = 10;
    		ptr_one->PI = 3.14;
    		ptr_one->A = 'a';

    		printf("First value: %d\n", ptr_one->i);
    		printf("Second value: %f\n", ptr_one->PI);
    		printf("Third value: %c\n", ptr_one->A);

    		free(ptr_one);

   		return 0;
	}

what is the use of -> in c.can we use it in all programming languages

3
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by deceptikon
0
#include<stdio.h>

	struct rec
	{
    		int i;
    		float PI;
    		char A;
	};

	int main()
	{
		struct rec *ptr_one;
		ptr_one =(struct rec *) malloc (sizeof(struct rec));

		ptr_one->i = 10;
    		ptr_one->PI = 3.14;
    		ptr_one->A = 'a';

    		printf("First value: %d\n", ptr_one->i);
    		printf("Second value: %f\n", ptr_one->PI);
    		printf("Third value: %c\n", ptr_one->A);

    		free(ptr_one);

   		return 0;
	}

what is the use of -> in c.can we use it in all programming languages

Can you use it in all programming languages? Only if the programming language recognizes -> as a valid operator.

0

what is the use of -> in c.

a->b is equivalent to (*a).b . It's syntactic sugar for accessing members of a structure through a pointer to an instance of the structure.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.