#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

Recommended Answers

All 2 Replies

#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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.