Hi All, I have following struct: struct timedate{ unsigned char sec; // 00 to 59 unsigned char min; // 00 to 59 unsigned char hrs; // 00 to 23 unsigned char date; // 01 to 31 unsigned char month;// 01 to 12 unsigned char year; // 00 to 99 }mystruct={00,00,12,01,01,02}; char mystring[12]; how can i use sprintf() or any other function to put 'timedate' into mystring ?? ---------------------------------------- Why is the following assignment illegai ?? unsigned char mych=1; sbit pin1 = P3^1; pin1 = mych; What i am trying to do is to assign the MSB or LSB of mych to pin1. How can that be done ?? Thankzz && Bye -Rocknmoon
"how can i use sprintf() or any other function to put 'timedate' into mystring ??" You will need to access each field in turn. Please, just ask one question at a time - otherwise the 'Summary' in the Thread list becomes meaningless, and it gets very difficult to see which answer in a thread relates to which question! Please repost your 2nd question as a separate thread.
What you really need is to read a book on C. Try this one: The C programming language, Kernighan & Ritchie. Regards, - Mike
"What you really need is to read a book on C" K&R is, indeed, the definitive reference for the 'C' language; however, as the authors point out, it is not intended to teach you how to program in 'C'. I think what Rock really needs is a book on how to program in 'C'. If his (or his employer's) resources stretch to it, a course on 'C' programming would be even better. Then get K&R!