
Originally Posted by
godatguitar Hey guys....
Can anyone help me here?
I am trying to read from SBUF on the 8051 and put it into an integer, so converting ascii to int i suppose...?
Here is the code that doesnt work atm...
xcoord1 = (int)SBUF;
xcoord1 = xcoord1 - 48;
Am I doing this wrong?
Cheers
I would have thought so!.
I've told you how to do it in Delphi, surely C has similar string handling facilities?. As I mentioned before, I can't help you with C - but Delphi, Pascal, and BASIC all have this facility - I can't believe C doesn't!.
How about something like this?, which I just downloaded off a C tutorial, it reads a string then a number from a file directly into the relevent variables - as I understand it you can read the serial port in the same way?.
Code:
/* Open file for input */
ifp = fopen(ifilename,"r");
/* Read data */
fscanf(ifp,"%s %d",name,&idNum);