From arifa.khan at ultratone.co.uk Tue Jan 4 10:25:08 2011 From: arifa.khan at ultratone.co.uk (Arifa Khan) Date: Tue, 4 Jan 2011 10:25:08 +0000 Subject: string handling [Scanned] Message-ID: <7157CAB7CBF2934290F7DA0150C12B7F24BE6AA547@NED.ctu.local> Hi, I'm trying to do some string manipulation, however I don't seem to be getting the response I expect. To compare individual characters in one string to another, as follows: int lettercode(char letter[], unsigned long dest) { int len; char compare[27]; strcpy(compare, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); len = strlen(letter); uart_send_num(len); uart_send_num(letter[0]); // the result of this comes up as "00/" if(!(strcmp(&letter[0],'H'))) // I've even tried if(!(strcmp(letter[0],'H'))) and if(!(strcmp(letter[0],"H"))) and if(!(strcmp(letter[0],compare[7))) { uart_send('k'); } ... int main(...) { ... char sentence[256]; char compare[27]; int sentence_len; strcpy(sentence, "HELLO"); strcpy(compare, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); sentence_len = strlen(sentence); lettercode(sentence,0x31000000); ... } Any advice? Thanks! Arifa Khan Embedded Engineer T +44 (0)1233 625252 F +44 (0)1233 645897 arifa.khan at ultratone.co.uk [cid:personal272ae.jpg] Ultratone Scientific Instruments Ltd., Kingsnorth Technology Park, Wotton Road, Ashford, Kent, TN23 6LN. Company registration number 01321345 IMPORTANT NOTICE. Confidentiality: This e-mail and its attachments are intended for the above named only and may be confidential. If they have come to you in error you must take no action based on them, nor must you copy or show them to anyone; please reply to this e-mail and highlight the error. Security Warning: Please note that this e-mail has been created in the knowledge that Internet e-mail is not a 100% secure communications medium.We advise that you understand and observe this lack of security when e-mailing us. Viruses: Although we have taken steps to ensure that this e-mail and attachments are free from any virus, we advise that in keeping with good computing practice the recipient should ensure they are actually virus free. Monitoring and Scanning: We have monitoring and scanning systems in place in relation to emails sent and received to: monitor / record business communications; prevent and detect crime; investigate the use of the Company's internal and external email system; and provide evidence of compliance with business practices. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: personal272ae.jpg Type: image/jpeg Size: 22778 bytes Desc: personal272ae.jpg URL: