我想访问 loadconfig 函数中的一个值,但总是出错:
请求'LoadConfig'中的成员'a',它是非类类型'int()'</p>
string trainData, testData, simName;
int b, i;
int LoadConfig()
{
int a;
ifstream fin("kddcup.txt");
while(getline(fin,trainData))
{
// do whatever to the string "line"
// cout << i + 1 << " "<< trainData << endl;
char *pcg = strdup(trainData.c_str());
//pcg=(char *)malloc(42);
trainData = strtok(pcg,",");
i=1;
while (pcg != NULL)
{
int tint=atoi(pcg);
int tmp[43];
//printf ("%s",pcg);
tmp[i]=tint;
pcg = strtok (NULL, ",");
//printf("value = %d \n",tmp[i]);
if (i==5)
{
a = tmp[i];
printf("value a= %d \n",a); //access this a
}
else if(i==6)
{
b=tmp[i];
//printf("nilai b = %d \n",b);
}
i++;
}//while pcg
}
// getline(fin, trainData);
}
int main()
{
int r;
LoadConfig();
// I WANT access from here
LoadConfig.a = new LoadConfig();
printf("output fungsi main = %d ",r);
}