Go Down

Topic: Short question about SD (Read 1 time) previous topic - next topic

Mastino

So how should I convert 1 2 3 to 49 50 51?

PaulS

Quote
So how should I convert 1 2 3 to 49 50 51?

Is this a trick question? Add 48 to each digit (or '0'). If you want the compiler to do the work for you:

Code: [Select]
int fileNumber = 814;
char fileName[12];
sprintf(fileName, "LOGGE%03d.CSV", fileNumber);

will result in fileName containing "LOGGE814.CSV".

If fileNumber were 22, instead, fileName would contain "LOGGE922.CSV".

Mastino

Thank you very much PaulS! I would never come to this code by myself.. With all sprintf and other funny things. :)
Thanks you my code is working and I`am one step closer to finish the code!

Go Up