我想将 TCHAR 转换为 int,但是当我转换它时,我将 ASCII 值转换为 int,而不是数字值。
代码:
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int converttoint()
{
TCHAR tchar[2];
wcscpy_s(tchar, TEXT("5"));
int i = tchar[0];
cout << i << endl;
return i;
}
int main(int argc, _TCHAR* argv[])
{
converttoint();
string in;
cin >> in;
}
Output: 53
Run Code Online (Sandbox Code Playgroud)
但我希望我能成为5岁。
如何才能做到这一点?