Thread: What does -> do?

  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    2

    What does -> do?

    I am learning how to program in C, and I'm wondering what some things do in my tutorial program.

    Code:
    printf("%c -> ", i);
    What does this do?
    Here it is in context.
    Code:
    int main()
    {
        int u = 65;
        int l = 97;
        
        for(int i = l; i < (l + 26); i++)
        {
            printf("%c -> ", i);
            for (int j = u; j < (u + 26); j++)
            {
                if (j == (u + 25))
                {
                    printf("%c", j);
                }
                else
                {
                    printf("%c,", j);
                }
            }
            
            printf("\n");
        }
        return 0;
    }
    Thank you.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    So have you compiled and run this example?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    In this context, it's just two characters that are printed as-is to the screen in the first printf statement. They don't do anything special; most characters passed to printf are just printed directly.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  4. #4
    Registered User
    Join Date
    Aug 2013
    Posts
    2
    Thank you. I'm surprised I missed that when I ran the program.

Popular pages Recent additions subscribe to a feed

Tags for this Thread