Page 1 of 1

Two Lines with sprintf?

PostPosted: Sun Feb 10, 2013 5:09 pm
by Soullem
Is there a way that you can have an enter in a sprintf so when it shows it has two lines?
This would make it so much easier to code the talking.

Heres an example:

sprintf(text,"hello mister man, what would" NEXTLINE "you like to do?");

would return,

hello mister man, what would
you like to do?


Also if I were to create a two dimensional array for a string how would it be formatted?
string[maxchar][myvar1][myvar2]

or

string[myvar1][myvar2][maxchar].

Re: Two Lines with sprintf?

PostPosted: Sun Feb 10, 2013 5:44 pm
by MrJolteon
Code: Select all
sprintf(text,"hello mister man, what would\nyou like to do?");

Re: Two Lines with sprintf?

PostPosted: Sun Feb 10, 2013 6:10 pm
by Soullem
\n right? got it thanks a lot.

+1 for the speed!

But also how would I go about making the char array?

Re: Two Lines with sprintf?

PostPosted: Sun Feb 10, 2013 6:36 pm
by MrJolteon
Soullem wrote:\n right? got it thanks a lot.

Yes, \n.

But also how would I go about making the char array?

I don't know anything about making arrays.

Re: Two Lines with sprintf?

PostPosted: Sun Feb 10, 2013 6:46 pm
by Soullem
Hakuna Matata, Thanks for the help!

Re: Two Lines with sprintf?

PostPosted: Sun Feb 10, 2013 6:54 pm
by MrJolteon
No problem.

Re: Two Lines with sprintf?

PostPosted: Sun Feb 10, 2013 7:36 pm
by lcl
For arrays, you do it like this:
Code: Select all
char myStringArray[5][5][256]

This example would create 5 * 5 strings with the length of 256 characters. :)

Re: Two Lines with sprintf?

PostPosted: Sun Feb 10, 2013 7:55 pm
by Soullem
Thanks a bundle LCL. I was unsure about the order.