I think this is a very simple question but I haven't been able to find the answer in my book.
This is how I want the output to look
but I am getting
my printf command looks like
Code:
printf("Process %2d of %d on %s\n", rank, size, name);
I thought the 2 preceding the first d would force the width of the first printed int to be two digits wide. Apparently I am missing something. Thanks in advance.
EDIT: I got it to work with this method
Code:
if (rank < 9) {
printf("Process %d%d of %d on %s\n", 0, rank, size, name);
}
else {
printf("Process %2d of %d on %s\n", rank, size, name);
}
but there has to be an easier way than this.