1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C statement, I don't know what it does

  1. Jan 2, 2012 #1
    1. The problem statement, all variables and given/known data
    What does this statement do?
    sprintf(fname,"%5.5i-%5.5i.%5.5i-%5.5i",1,*nx,1,*ny);

    from my knowledge of c,
    % is modulus,
    I don't know what the . is doing, according to wikipedia, it is element selection to reference
    I know that it is storing the name of a file in the buffer, fname.
    but to what "%5.5i-%5.5i.%5.5i-%5.5i" is doing, I have no bloody idea.

    I'm trying to rewrite it in python by the way.
    nx is number of rows in a matrix, ny the number of columns
    I can't see where 1 goes within "%5.5i-%5.5i.%5.5i-%5.5i"

    HELP PLEASE AHHHH


    2. Relevant equations



    3. The attempt at a solution
     
  2. jcsd
  3. Jan 2, 2012 #2

    nsaspook

    User Avatar
    Science Advisor

  4. Jan 3, 2012 #3

    Mark44

    Staff: Mentor

    Not in this context. The % is used at the start of each conversion specifier so that sprintf can convert each of the four arguments after the format string (the second argument).
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook