If you have any questions, contact us. -- Linux general technology-Linux programming and kernel information. The following is a detailed description. Today, when I want to write a resume for creating a txt version under the character terminal, I encountered a problem, that is, the process of converting the numeric string into an integer number. I found many places on the Internet, I don't know if such a library function is available in linux. Can anyone tell me?
(There is no way to write one on your own at last, but it is quite helpful. Please give me more criticism !)
# Include
# Include
Int converse (char * p)
{
Int I, j;
Int integer, result = 0;
Int length = strlen (p );
Int temp = length-1;
For (I = 0; I {
Integer = 1;
For (j = temp; j> 0; j --)
{Integer * = 10 ;}
Temp --;
Result + = (p
-'0') * integer; }
Return result; } Int main (int argc, char * argv []) { Int m; M = converse (argv [1]); Printf ("the result is: % d \ n", m ); Return 0; }
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.