??? 12/18/09 21:05 Modified: 12/18/09 21:06 Read: times |
#171746 - = vs == Responding to: ???'s previous message |
Stefan Kanev said:
I do not use C, but i never read that "a=b" is function.
Thanks for taking the time Stefan. Don't forget that in C = is an assignation, not a comparison, so the line while ((*i2c_buffer = *str)!='O') //Finally I realised I should use a O instead of a 0 while posting here - sadly still no backslash assigns the value pointed to by str to the address pointed to by i2c_buffer, then compares the value to 'O' and returns true if they are not equal. I finally fixed it (I think) like this. void send_i2c_data ( unsigned char *str ) { unsigned char i2c_status; unsigned char idata *p_i2c_buffer = &i2c_buffer; while ((*p_i2c_buffer = *str)!='O') { str++; p_i2c_buffer++; buffer_count++; } i2c_status = i2c_transmit(0x60); //To be used later on when this function is expanded } i2c_buffer is declared earlier as unsigned char idata i2c_buffer[20]; |
Topic | Author | Date |
Some help with copying strings in C (again) | 01/01/70 00:00 | |
Blast. | 01/01/70 00:00 | |
? | 01/01/70 00:00 | |
Crunched function | 01/01/70 00:00 | |
maybe | 01/01/70 00:00 | |
= vs == | 01/01/70 00:00 | |
ok | 01/01/70 00:00 | |
'\0' | 01/01/70 00:00 | |
just for record | 01/01/70 00:00 | |
Both are ok. | 01/01/70 00:00 | |
A warning - not an error | 01/01/70 00:00 | |
Yes. Should have said "warning" | 01/01/70 00:00 | |
but | 01/01/70 00:00 | |
Assign always spreads to the left, but mind the data type | 01/01/70 00:00 |