ok so i need help i have no clue how to create a .txt. file and add it to the file because it seems to not exist. or when i do create a file that is readable and doesn't give me the error code of the indata file i cannot find the output if it was even created. or if the data was read from the in data please help me understand ALL CODING IS DONE IN XCODE FOR MAC'S
//open your input file <--- # 3
indata.open("numbers.txt");
if (indata.fail())
{
cout << " file does not exit\n";
exit(1);
}
//open your output file <--- # 3
odddata.open("OddNumbers.txt");
if (odddata.fail())
{
cout << " file does not exit\n";
exit(1);
}
evendata.open("EvenNumbers.txt");
if (evendata.fail())
{
cout << " file does not exit\n";
exit(2);
}
graph.open("Graph.txt");
if (graph.fail())
{
cout << " file does not exit\n";
exit(3);
}
//read from your input file (similar to cin) <--- #4
indata >> num;
max=min=num;
while (!indata.eof())
{
if(num != 0)
{
if(num %2 == 1)
odddata << num << endl;
else
evendata << num <<endl;
count++;
sum += num;
if (num > max)
max=num;
else if (num < min)
min = num;
//draw the bar graph for this data item
graph << num <<":\t";
for (i=0; i < num; i+=2)
{
graph << "*";
}
graph << endl;
}
//get the next number
indata >> num;
}