Jump to content
  • Advertisement

Archived

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

RegularKid

Sorry, but I need just a little more help...

This topic is 6539 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

Ok. Here is what I have so far for my font engine (of course I''m going to change the printf with bitmap drawing routines...but this is just for testing it in dos mode). But when i compile and run it i get this: A A A A A A A A What am I doing wrong?! Here is the code... #include #include #include #include void PrintMessage(char *mytext) { int length = strlen(mytext); for(int i = 0; i < length; i++) { if(mytext = ''A'') { printf("A\n"); } else if(mytext[i] = ''B'') { printf("B\n"); } } } void main( void ) { PrintMessage("ABBAABAB"); } Any help would be great. thanks.

Share this post


Link to post
Share on other sites
Advertisement
Well, I think its when you do:
if(mytext = ''A'')
{
printf("A\n");
}
else if(mytext = ''B'')
{
printf("B\n");
}

It should be
if(mytext[i] = ''A'') //See the diff
{
printf("A\n");
}
else if(mytext[i] = ''B'')
{
printf("B\n");
}


PS: Why would you do that?, also, you could of done a switch, doesnt matter though.

Share this post


Link to post
Share on other sites
RegularKid,

Two things:

First, your first ''if'' is missing the subscript from mytext.

Second, both ''if''s have ''='' (assignment) instead of ''=='' (equality). So, you''re always going to get a TRUE (non-zero) result from the first ''if'' and, therefore, always print an ''A''.

Dave

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!