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