Set readFile(Set In, char *name)
{
ifstream fin;
fin.open (name);
cout << "Value of name in readFile:" << name << endl;
if (fin.fail())
{
cerr << "failure to open" << endl;
exit(0);
}
int temp = 0;
fin >> temp;
In.setMax(temp);
int *point = newint[temp];
In.setPointer(point);
for (int i = 0, count = 0, junk = 0; i < In.getMax(); i++)
{
if(In.clone(In, point[i]))
{
fin >> point[i];
count++;
}
else
{
fin >> junk;
}
}
fin.close();
return In;
}
1 2 3 4 5 6 7 8 9 10
int main(int argc, char **argv)
{
Set A,B,C;
char *inChar = argv[1];
int inInt;
cerr << "value of arg in main: " << argv[1] << endl;
readFile(A, inChar);
cerr << "main second" << endl;
inInt = A.getLength();
readFile(B, argv[1], inInt);
output:
a.out assign_test2.cpp
1 2 3 4 5 6 7
value of arg in main: assign_test2.in
Value of name in readFile: assign_test2.in
*** glibc detected *** a.out: double free or corruption (fasttop): 0x00000000012ac2f0 ***
Bunch of seemingly random numbers:
Aborted (core dumped)
I hope this is sufficient. I posted the relevant areas for the problem. Let me know if you need more of the code and thank you.