#include<iostream>
#include<fstream>
#include<sstream>
#include<stdlib.h>
#include<math.h>
#include<iomanip>
using namespace std;
int main()
{
int NUM_Object,NUM_Medoid;
cout<<"How many menus u have?"<<endl;
cin>>NUM_Object;
cout<<"How many Medoids(k) do you want?"<<endl;
cin>>NUM_Medoid;
ifstream myfile("Nutrient.txt", ios::in);
int i,j,k,count;
count = 0;
float TEMP_num;
double Object[NUM_Object][5];
double Medoid[NUM_Medoid][5],Medoid_New[NUM_Medoid][5],SUM_Distance[NUM_Medoid],SUM_Pij[NUM_Medoid],
SUM_P[NUM_Medoid],SUM_Distance_New[NUM_Medoid],SUM_Pij_New[NUM_Medoid],SUM_P_New[NUM_Medoid];
long double Distance[NUM_Object][Object];
for(i=0;i<NUM_Object;i++)
{
for(j=0;j<NUM_Object;j++)
{
Distance[i][j] = 0;
}
}
string line;
if(myfile.is_open())
{
while(myfile >> line)
{
i=0;
while(line[i]!='\0')
{
if(line[i]==',')
{
line[i]=' ';
}
i++;
}
string temp(line);
istringstream iss(temp);
string word;
j=0;
while(iss >> word)
{
TEMP_num = atof(word.c_str());
Object[count][j] = TEMP_num;
j++;
}
count++;
}
}
for(i=0;i<NUM_Object;i++)
{
for(j=0;j<5;j++)
{
cout<<Object[i][j]<<" ";
}
cout<<endl;
}
myfile.close();
}
when i try to declare Distance[NUM_Object][NUM_Object]//(line28) when i run on server, it shows "Segmentation fault (core dumped)" i have no idea whats wrong with my code. Please help.
(NUM_Object = 854)