Conversion between strings and numbers in C/C ++/MFC

Source: Internet
Author: User

Previously writtenProgramYou need to convert the string you entered into a floating point number. My solution is to write

The function declaration is similar to: Float cstring2float (cstring Str,

In fact, the conversion between strings and numbers C has provided a large number of functions that we can fully utilize

These ready-made functions improve program robustness. Common conversion functions include:

Atof char * to float

Atoi char * to int

Atol char * to long

In fact, this type of conversion function is very many. Because I don't feel good about classification, I only list the preceding functions.

To view other conversion functions, enter data conversion routines in msdn,

You can find other available conversion functions in this topic. For more information, see msdn.

_ Atoi64 strtol strtodd _ wtoi _ wtoi64 _ wtol wcstol wcstod _ tcstol _ tcstod

Strtoint strtointex strtoint64ex

_ ITOA _ i64toa _ ui64toa _ ltoa _ ultoa

_ Itow _ i64tow _ ui64tow _ ltow _ ultow

If you are not using vc6, but vs2003 or later, you can use char * for conversion *,

What if you are using Unicode encoding? refer to conversion between Unicode and MBCS.


Related Article

Contact Us

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: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.