28 Sep, 2012, arholly wrote in the 1st comment:
Votes: 0
Hi:
I'm pretty sure this is an easy problem, but I admit I'm not real knowledgeable on string manipulation.

My existing code is below. What I want to do is make it so that it can accommodate up to 10 "+"'s easily and so I have them nicely spaced so I can then add a second column and third column the same way. Obviously, if there is an easier way to do it, I'm all for it. I do know I'll need to remove the \n\r from the end in order to accommodate the second and third column.
send_to_char ("Str: ", user);
if (get_curr_stat(ch,STAT_STR)<=0)
{
send_to_char( ".", user);
}
else
{
while (statcount < get_curr_stat(ch,STAT_STR))
{
send_to_char( "+", user);
statcount= statcount+1;
}
}
send_to_char("\n\r", user);
28 Sep, 2012, donky wrote in the 2nd comment:
Votes: 0
You should really learn the common format that sprintf takes (and printf as well), as they're not only useful but pretty cool. Using this formatting, you should be able to say something like "display N +s". Not only that, but if you wanted to get fancy, you could align the dots and pluses to the right (or center) with leading (and trailing spaces if centered).

if (get_curr_stat(ch,STAT_STR)<=0)
send_to_char ("Str: .\r\n", user);
else {
char buf[100];
sprintf(&buf[0], "Str: %.*s\r\n", get_curr_stat(ch,STAT_STR), '+');
send_to_char (&buf[0], user);
}


Check it out.
0.0/2