could someone explain this line to me please

This is a discussion on could someone explain this line to me please within the C Programming forums, part of the General Programming Boards category; Okay I normally program in c++ but the book I use to learn win32 is written in c. I've come ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    178

    could someone explain this line to me please

    Okay I normally program in c++ but the book I use to learn win32 is written in c. I've come across a couple of line that i don't understand, can someone please explain these to me.
    The first one is:
    Code:
    int iLength;
    TCHAR szBuffer[40];
    iLength = (szBuffer, TEXT("The sum of %i and %i is %i"),  //i really don't get the %i part
                      iA, iB, iA + iB);
    TextOut(hdc, x, y, szBuffer, iLength);
    basically the only one that gets me is the i length = statment.

    The other one is
    Code:
    wsprintf(szBuffer, TEXT("%5d"),  //i don't get the %5d part
    Thanks for any help.
    Oi Oi Oi!!!!

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    95
    %i just signafies that a variable is in the place of the %, so %d means an integer, so if you wanted to output to the screen someones name and age from variables you would do something like:

    printf("Your name is: %s and your ages is %d",name,age);
    so all your text goes inside "" and then after that you put all the variables that you used from left to right seperating them with commas.

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    178
    Allright that pretty much clears things up. THanks a bunch.
    Oi Oi Oi!!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing Length of Input and the Limited Input
    By dnguyen1022 in forum C Programming
    Replies: 33
    Last Post: 11-29-2008, 03:13 PM
  2. Can anybody explain this line?
    By g4j31a5 in forum C++ Programming
    Replies: 2
    Last Post: 10-31-2008, 04:59 AM
  3. Finding carriage returns (\c) in a line
    By JizJizJiz in forum C++ Programming
    Replies: 37
    Last Post: 07-19-2006, 05:44 PM
  4. Adding Line numbers in Word
    By Mister C in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 06-24-2004, 08:45 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21