Understanding C Statements: sprintf fname for File Name Formatting

  • Thread starter Thread starter vorcil
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
vorcil
Messages
395
Reaction score
0

Homework Statement


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


Homework Equations





The Attempt at a Solution

 
Physics news on Phys.org
vorcil said:
from my knowledge of c,
% is modulus,
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).