I'm using an ordinals function for my current program, I found the code written in javascript so I decided to translate it into C++, but I have a whole lot of errors that are coming up now...
System::String^ getOrdinal(int number) { System::String^ ord = 'th';
if((number % 10) = 1 && (number % 100) != 11) { ord = 'st'; } if((number % 10) = 2 && (number % 100) != 12) { ord = 'nd'; } if((number % 10) = 3 && (number % 100) != 13) { ord = 'rd'; } return ord; }
The errors are:
-
Everytime I have used the varaible 'ord' including the initialization I get an error saying that the computer can't convert string to int type. I think this is being caused by the int default return type rule. But that should not even be being used, because I have defined the return type as String anyway.
-
on each of the if statments I get an error saying ' left operand must be 1-value' and this error is one I have no ideas about...
Please reply asap...
Visual C++8
|