Advertisement

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

Started by July 24, 2000 08:23 PM
1 comment, last by RegularKid 24 years, 5 months ago
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 = ''B'') { printf("B\n"); } } } void main( void ) { PrintMessage("ABBAABAB"); } Any help would be great. thanks. </i>
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 = ''A'') //See the diff<img src="smile.gif" width=15 height=15 align=middle><br>{ <br>printf("A\n");<br>}<br>else if(mytext = ''B'')<br>{<br>printf("B\n");<br>}<br><br><br>PS: Why would you do that?, also, you could of done a switch, doesnt matter though.<br> </i>
Advertisement
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

This topic is closed to new replies.

Advertisement