Two Lines with sprintf?

Game Editor comments and discussion.

Two Lines with sprintf?

Postby Soullem » Sun Feb 10, 2013 5:09 pm

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].
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: Two Lines with sprintf?

Postby MrJolteon » Sun Feb 10, 2013 5:44 pm

Code: Select all
sprintf(text,"hello mister man, what would\nyou like to do?");
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Two Lines with sprintf?

Postby Soullem » Sun Feb 10, 2013 6:10 pm

\n right? got it thanks a lot.

+1 for the speed!

But also how would I go about making the char array?
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: Two Lines with sprintf?

Postby MrJolteon » Sun Feb 10, 2013 6:36 pm

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.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Two Lines with sprintf?

Postby Soullem » Sun Feb 10, 2013 6:46 pm

Hakuna Matata, Thanks for the help!
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: Two Lines with sprintf?

Postby MrJolteon » Sun Feb 10, 2013 6:54 pm

No problem.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Two Lines with sprintf?

Postby lcl » Sun Feb 10, 2013 7:36 pm

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. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Two Lines with sprintf?

Postby Soullem » Sun Feb 10, 2013 7:55 pm

Thanks a bundle LCL. I was unsure about the order.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest