#include"stdafx.h"#include<string>#include<vector>#include<iostream>#include<sstream>#include<stdio.h>#include<stdlib.h>using namespacestd;//SstreamstringINT2STR1 (intN) {Ostringstream oss; OSS<<N; strings =Oss.str (); returns;}//sprintfstringINT2STR2 (intN) { Chartemp[ -]; sprintf_s (temp,"%d", N); stringstr =temp; returnstr;}//SstreamintStr2int1 (strings) { intN; Istringstream ISS; Iss.clear (); ISS.STR (s); ISS>>N; returnN;}//sscanfintStr2int2 (strings) { intN; sscanf_s (S.c_str (),"%d", &n);//scanf Front Plus s for input str into n returnN;}//StoiintStr2int3 (stringSint Base){//Base: Binary intn = Stoi (s, nullptr,Base); returnN;}//C_strConst Char* Str2cchar (strings) { //const char* SS = S.c_str ();//error because S is destructor, SS points to spam Charc[ -]; strcpy_s (c, S.c_str ()); returnC;}//atoiintCchar2int (Const Char*s) { //Char buffer[100]; intn =Atoi (s); returnN;}Char* Int2char (intN) { Charbuffer[ -]; _itoa_s (n, Buffer,Ten); returnbuffer;}int_tmain (intARGC, _tchar*argv[]) { //cout << str2int1 ("1234") << Endl; //cout << str2int2 ("1234") << Endl; //cout << int2str1 (1234) << Endl; //cout << int2str1 (1234) << Endl; //string S1 = "123455"; //const char* SS1 = Str2cchar (S1); //char s2[] = "123455"; //const char* SS2 = s2; //cout << cchar2int (SS2) << Endl; Char* C = Int2char (1234); cout<< *c <<Endl; return 0;}
Conversion between "C + +" int, const char*, char*, char, string