Welcome to the Builder Academy

Question Formatting a string in do_score

More
18 Sep 2021 01:55 - 18 Sep 2021 02:07 #9914 by Darklands
I'd imagine I may be overcomplicating this, but if you wanted to do an ascii border around your score sheet similar to this

|
|
|Score information for %s               |      <----Fixed border
|
|

What is the best way to format the string to allow for a max character length that would keep the "border" the same, regardless of the length of the string 
(within limits of course)

Thanks
 
Last edit: 18 Sep 2021 02:07 by Darklands. Reason: Fixed title of post

Please Log in or Create an account to join the conversation.

More
18 Sep 2021 06:10 #9915 by Darklands
I'm trying to play with it and use justify to position, Was wondering more than anything if there is a cleaner way to design a border and keep it the same.

Please Log in or Create an account to join the conversation.

More
18 Sep 2021 06:20 #9916 by Darklands
I think I've got it sorted through left/right justification. There is probably a more efficient way but for now this will work :)

Please Log in or Create an account to join the conversation.

More
19 Sep 2021 00:51 - 19 Sep 2021 00:52 #9917 by thomas
No, left-right justification (%-30s, %30s) is the way to go for this in C; you'll probably not find a better way.
Last edit: 19 Sep 2021 00:52 by thomas.
The following user(s) said Thank You: jandulio

Please Log in or Create an account to join the conversation.

More
12 Oct 2021 18:53 #9951 by soth
I use the exact same method Thomas uses. if you do a custom score sheet and want exact place holders you will use this a lot. Nothing better than seeing a custom score sheet with everything lining up correctly :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.206 seconds