Test of the 2016.5.21--atoi () function

Source: Internet
Author: User

To test the function atoi () function:

The Atoi () function converts a string type to an integer type

Code:

1#include"stdafx.h"2#include"iostream"3#include"Vector"4 //#include <stdlib.h>5 using namespacestd;6 7 int_tmain (intARGC, _tchar*argv[])8 {9     CharStr[] = {" A"};//This cannot be defined as a string type, Error: Error C2664: "int atoi (const char *)": cannot convert parameter 1 from "std::string [1]" to "const char *"Ten     intm =0; Onem = atoi (str) *3; A     //n = m * 2; -cout << M <<Endl; -System"Pause"); the     return 0; -}

Note When defining a string type, it cannot be defined as a string, but is defined as a char type. Otherwise error:error C2664: "int atoi (const char *)": cannot convert parameter 1 from "std::string [1]" to "const char *"

  L9char str[] = { "n" }; Cannot be written like this char str[] = {"12", "45"}, Error: Error C2078: too many initializers

  

Broken read:

string is double quotation mark "", Curly brace {}!!!! , Python is single quote ' ', bracket []

  Attention to various types, after checking that I can not convert from the XXX type to YYY type

Test of the 2016.5.21--atoi () function

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: info-contact@alibabacloud.com 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.