#include <iostream>
#include <stdlib.h>
#include <cstring>
using namespace std;
int main()
{
string ID[]={"620301025123"}; //ID array
long long int IC[10]={0}; //IC array
// loop to change the ID string to Array IC. I will want to increase the size
// of ID array, later on, to put in new data but for now, I'm just using one data
// which is "620301025123" first.
for(int i = 0; i < 10; ++i){
IC[i]= {atoll(ID[i].c_str())};
}
}
我得到的错误是:
14 29 C:\ Users \ ASUS \ Desktop \ Assign1 \ Untitled3.cpp [警告]扩展初始化列表仅适用于-std = c ++ 11或-std = gnu ++ 11 * /
首先:它是C ++中的#include <cstdlib>
。
然后,您的问题似乎不是转换为long long
,而是字符串的初始化,至少这是警告(不是错误)所说的。您正在使用扩展初始化程序列表,它们是C ++ 11,但尚未激活C ++ 11支持。
警告告诉您如何激活它。
最后:不要养成使用using namespace
的习惯,至少不是全球性的。你可以在特定的符号上使用using
,但即便如此,我只在本地做,而且从不全局。