Skip to content
Home » what is ‘- ->’ operator in C

what is ‘- ->’ operator in C

Learn about C Program to show ‘- ->’ operator in C in the below code example.
Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

C Program to show ‘- ->’ operator in C:

These are two operators namely Decrement(- -) and greater than(>).Hence overall operation of this operation goes in this way ,It decrements the value of given variable and compares(>) with 0. It’s combined feature is used in different ways. Here are one of the Example.

Example:
#include <stdio.h>
int main()
{
    int p=8;
    while (p --> 0) // p decrements to 0 by 1
    {
        printf("%d ", p);
    }
}

7 6 5 4 3 2 1 0

In above example it decrements the value of p by 1 till 0 ,which is quite similar to another code

#include <stdio.h>
int main()
{
    int p=8;
    while(p>0)
    {
        p=p-1;
        printf("%d ", p);
    }
}

7 6 5 4 3 2 1 0

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Also Read:

‘->’ operator in struct