Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Tiso

Displaying a multiple line array

This topic is 6547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Me and a friend are making a card game with ascii graphics and I''m having trouble displaying the card which is put into an array. Here is how it should look: +----------+ / / / / / / / / / / / / +----------+ All of that including the symbols is stored within one array. When I go to display it with a for loop it gives me an illegal opperation error. It looks something like this: for(x=0;x<90;x++) { printf("%s",card_master[x]); } But the card won''t display on multiple lines. So I tried this to get each line work: for(x=0;x<90;x++) { printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",card_master[x]); } Another illegal operation error. Is there a way I can fix this? ............ Guardian Angel Interactive

Share this post


Link to post
Share on other sites
Advertisement
Well if card_master is declared to something like

char card_master[90][constant-value];

then the arrays aren't null terminated. '\0'





Edited by - Claus Hansen Ries on June 21, 2000 11:51:00 AM

Share this post


Link to post
Share on other sites
You cant tell if card_master[x] isn't a string or not without seeing its declaration. (or compiler errors )

if you declare it as 2dim array:
char card_master[10][256];

you would have 10 strings with each 256 chars.

and it would be used as:

        

for( int i=0; i<10; i++ )
{
sprintf( card_master<i>, "str number %i", i );
}

[/source]

and to print them out

[source]

for( int i=0; i<10; i++ )
{
printf( card_master[i] ); // or printf( "%s", card_master[i] );
}



this was once a replay on a removed message =)

Edited by - Claus Hansen Ries on June 21, 2000 12:17:03 PM

Edited by - Claus Hansen Ries on June 21, 2000 12:18:25 PM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!