Using a size_t variable as a width and precision modifier in printf
OK, the title might sound a bit confusing. I'm currently converting code to work on 64 bit machines. One problem I'm having right now is the following call to printf:
Code:
int readLen;
pLine = fgetln( pFile, &readLen );
printf(" %*.*s", readLen, readLen, pLine );
This is the code working on a 32 bit machine. But fgetln requires a size_t argument so I changed it to:
Code:
size_t readLen;
pLine = fgetln( pFile, &readLen );
printf(" %*.*s", readLen, readLen, pLine );
Now the printf doesn't work any more, because the width and precision modifiers have to be of type int (see printf - C++ Reference)
Can someone tell me what's the best way to solve this problem (i.e. get the printf working with the width and precision modifiers)?
Thanks a lot!