Re: atoi() check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Deshpande Bansidhar(IFIN DC AI) wrote:

Hi all

I have following code.
I want to add error handler for atoi() function.

E.g.

char *ch;
int num;

/*Read ch here*/

Num = atoi(ch);

But before calling atoi I want to make sure that ch is pointing to numberic
string. How should I do this. I can manually write some function to check this. But
is there
Any library function inbuilt to achieve the same ?




How about using strtod instead? It seems to be able to give meaningful respond regarding the validity of the string.

Just my 2c.


Liguo (Leo)




Thanks & regards,
Bansidhar A. Deshpande
Software Engineer Infineon Technologies India Pvt. Ltd. Discoverer Building. I.T.P.L., White Field Road, Bangalore -560066 Phone: +91-80-51392011 Extn : 2066
Fax: +91-80-8410012



*Disclaimer* This e-mail and any attachments are confidential and may be subject to legal or some other professional privilege. They are intended solely for the attention and use of the named addressee(s). They must not be disclosed to any person without authorization. This e-mail and any attachments are also subject to copyright. They may only be copied or distributed with the consent of the copyright owner. If you are not a named addressee you must not use, disclose, retain or reproduce all or any part of the information contained in this e-mail or any attachments. If you have received this email by mistake please notify the sender immediately by return email and delete or destroy all copies of the email. Any confidentiality, privilege or copyright is not waived or lost because this email has been sent to you by mistake.







[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux