编译此上Codepad:转换char类型的阵列划分为整数变量
#include <iostream>
using namespace std;
void main (void)
{
char ch[2];
int value;
cout<<"Enter two integers between 0-9"<<endl;
cin.getline(ch,2);
//testing with char array
//(...)
//how could I do operations like '*', '+', '-', or '/' to the char arrays
}
给出:
Line 4: error: '::main' must return 'int' compilation terminated due to -Wfatal-errors.
例如:
比方说ch[0]='5'
和ch[1]='3'
什么我是否需要这样做,我可以做ch [0] - ch [1] = 2并存储到一个int值
谢谢,现在我明白了。我忘记了数组中最后一个索引位置包含null –