Formatting a string in do_score

  • Darklands
  • Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 2 months ago - 1 year 2 months ago #9914 by Darklands
Formatting a string in do_score was created 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: 1 year 2 months ago by Darklands. Reason: Fixed title of post

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

  • Darklands
  • Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 2 months ago #9915 by Darklands
Replied by Darklands on topic Formatting a string in do_score
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.

  • Darklands
  • Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 2 months ago #9916 by Darklands
Replied by Darklands on topic Formatting a string in do_score
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
1 year 2 months ago - 1 year 2 months ago #9917 by thomas
Replied by thomas on topic Formatting a string in do_score
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: 1 year 2 months ago by thomas.
The following user(s) said Thank You: jandulio

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

More
1 year 1 month ago #9951 by soth
Replied by soth on topic Formatting a string in do_score
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.183 seconds