Sorry, but I need just a little more help...
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>
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>
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
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
Popular Topics
Advertisement
Recommended Tutorials
Advertisement