Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fprintf C multiple spaces

Tags:

c

printf

Hello i'm new to C and have some confusion Regarding fprintf

I'm trying to create a Data table and i want it to look exactly like this:

Rectangle A                    Rectangle B 
SW corner   Height   Width     SW corner   Height   Width

Most of my confusion is coming from the white spaces, surely there is a better way than just adding an empty String.


1 Answers

You can use width specifier:

printf("[%5d] [%-5d]\n", 42, 42);
like image 115
pmg Avatar answered Aug 25 '26 08:08

pmg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!