I am using printf function to send data to serial port. The mcu has to send a number which may be upto 65535.
But for numbers larger than 32767, I was getting negative numbers. To test it I wrote following code
unsigned int i; for(i=32760;i<=32770;i++) printf("%d\n", i); //printf ("char %bd int %d long %ld\n",a,b,c);
What I was getting in VB application is
32760 32761 32762 32763 32764 32765 32766 32767 -32768 -32767 -32766
So I tried the same program in Pelles C for Windows . The result was perfect.
32760 32761 32762 32763 32764 32765 32766 32767 32768 32769 32770 Press any key to continue...
Can somebody tell me what is wrong here?
Thanks J Macmillan,
I solved my problem with your free service ;) I used %u instead of %d or %i & I am getting proper results now.
THANKS EVERYBODY!!!
Then you might like some free reference/learing resources for C programming:
blog.antronics.co.uk/.../08
As already noted, the above is all standard 'C' - nothing specifically to do with Keil or C51.
However, there are certain areas which do have issues specific to Keil C51;
eg, see: http://www.keil.com/forum/22199/
You have not been charged for this service.
he he he, Thanks!!!