Hi there,
I'm getting on pretty well with a project for uni I've got to do, although I'm currently slumped at a bit. I'm running a loop to constantly read numbers into a set of equations and I'm required to output these to an excel file. I've sussed making the Excel file as I require but I'm unsure as how to print out the variables into the file itself. Heres the snippet of code I'm using -
if ( v > 4.47 && v < 25 )
{
ofstream outFile ("H:\\workspace\\Windfarms2.csv");
outFile << "Wind Farm Data, Wind Speed, Power Generated" << endl;
outFile << s1, ss, p << endl;
outFile.close();
if (!outFile)
{
cout << "Error opening file" << endl;
return -1;
}
}
else if (v <4.47 || v==4.47)
{ cout << "The cut-in speed has not been reached, therefore power cannot be generated/n";}
else
{cout << "The Windspeed is too high, therefore power cannot be generated.\n";}
return 0;
}
while(!inFile.eof())
{
cout << "Error opening file" << endl;
}
In the code, s1, ss and p are the variables which are required to be printed out in the file. At this current stage, I know line 6 is wrong, but thats the part I'm stuck with.
Can anyone help atall?
And I know I've been warned on these forums about the errors which may be involved when using .eof, but my lecturer said I was just to use that :$!