正整数转string型

//正整形转换为string型
string FNumChangeCString(int i)
{
	//序号
	string SerialNumber;
	SerialNumber.resize(0);
	if (i < 0)
	{
		return SerialNumber;
	}
	if (i == 0)
	{
		SerialNumber.push_back('0');
		return SerialNumber;
	}
	//余数
	int Remainder = 0;
	while (i != 0)
	{
		Remainder = i % 10;
		SerialNumber.push_back(Remainder + '0');
		i = i / 10;
	}

	size_t Size = SerialNumber.size();
	size_t size = Size / 2;
	char temp;
	for (size_t i = 0; i < size; i++)
	{
		temp = SerialNumber[i];
		SerialNumber[i] = SerialNumber[Size - i - 1];
		SerialNumber[Size - i - 1] = temp;
	}

	return SerialNumber;
}

 

你可能感兴趣的:(常用函数调用)