将数组存储在VC ++中的INTEGER变量中。 [英] Store the numericals in char array into an INTEGER variable in VC++.

查看:217
本文介绍了将数组存储在VC ++中的INTEGER变量中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的场景如下:(C ++)

My scenario is as follows:(C++)

在char a [10]中,数组a []具有像'1' 2','3'等....

In char a[10], the array a[] has elements (numbers) like '1','2','3' etc....

说a [0] ='1';

a [1] ='2' ;

a [2] ='3';

Say a[0] = '1';
a[1] = '2';
a[2] = '3';

现在[]正在存储3个字符'1','2'和'3'。 我想将它存储为一个整数为123(整数123)。

Now a[] is storing 3 characters '1', '2' and '3'. I want to store this into an int as 123 (An integer 123).

如何在C ++中实现?

How to achieve this in C++ ?

推荐答案

a [3] = 0

之后,它是一个简单的 number = atoi(a)

After that, it's a simple number = atoi(a)

这篇关于将数组存储在VC ++中的INTEGER变量中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆