int displayed = 0;
…
for(…)
…
send_to_char(ch, "%-15s%s", skill_name, (++displayed % 4) ? "\r\n" : "");
for(a=0;a<10;a++) {
sprintf(buf, "1 2 3 4 5 6 7 8");
send_to_char(ch, "%-10s%s", buf, (a%2)?"\r\n":" ");
}
send_to_char(ch, "Character Level: %d", GET_LEVEL(ch));
void list_skills(struct char_data *ch)
{
const char *overflow = "\r\n**OVERFLOW**\r\n";
int i, sortpos, ret, a;
size_t len = 0;
char buf2[MAX_STRING_LENGTH];
len = snprintf(buf2, sizeof(buf2), "You know the following %ss:\r\n", SPLSKL(ch));
for(a=0, sortpos=0;sortpos <= MAX_SKILLS; sortpos++) {
i = spell_sort_info[sortpos];
if(GET_LEVEL(ch)>= spell_info[i].min_level[(int)GET_CLASS(ch)]) {
ret = snprintf(buf2 + len, sizeof(buf2) - len, "%-20s%s", spell_info[i].name, (a++%4 == 3)?"\r\n":" ");
if(ret< 0 || len + ret >= sizeof(buf2))
break;
len += ret;
}
}
if (len >= sizeof(buf2))
strcpy(buf2 + sizeof(buf2) - strlen(overflow) - 1, overflow);
page_string(ch->desc, buf2, TRUE);
}
I am learning C(using tbamud). I have a question. I am wanting to format some code and make it align.
Example:
Fire1 Fire2 Fire3 Fire4 Fire5
Lets say I want that above code to format after every for words
How I want it to output:
Fire1 Fire2 Fire3 Fire4(insert a \r\n)
Fire5
So I was thinking would it be something like this
thanks for the help!