On Thu, Mar 26, 1998 6:38 PM, Neal Lahndorff <mailto:stulahnd@ACS.EKU.EDU>
wrote:
>> 40 - (1/2 string length) to give you the starting position. Then print
> enough spaces to put you at the starting position and concatentate the
> strings.
In other words, (or in C, as the case may be)
short dist = 40 - (strlen(theString));
short count;
for (count = 0; count < dist; count++)
printf(" ");
Now, this is really happy code that doesn't cut many corners, but it's a
basis. A better way would be:
short dist = 40 - (strlen(theString));
short count;
char* outspc = malloc(dist);
for (count = 0; count < dist; count++)
outspc[count] = ' ';
printf("%s", outspc);
since the for loop does memory accesses instead of I/O processes...
Judson Powers Morgaelin MUD
powers@rjsonline.net telnet://mud.dwango.com:3000/
"Friends help you move... real friends help you move bodies."
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST