Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing to an output file

Status
Not open for further replies.

aaadetos

Programmer
Nov 21, 2004
54
US
I'm trying to write some code to an output file. The function reads data in text format and then tries to write results after the data has been processed in other source code. The resulting data (data to be written) is actually an array of values, but i get error c2679. The 2 codes are as follows:
Code:
//code 1: Code which returns the array of results
void dimpress(double *pD,int nSize)
{
	for (int t=0;t<nSize;t++)
	{
		double tdim[1],dimrw[1],dimpress[20],gwk[20],rwD;
		double tD,rD = 0.0;
		float Lw,rw;
		int K;

		CKuchukDlg MyClass;
		MyClass.m_fHLength = Lw;
		MyClass.m_fWellRad = rw;
		MyClass.m_iSLayer = K;
	
		Stfst = new Stehfest(nSize);	
		tdim[K] = (0.0002637*kh_md[K])/(por[K]*visc_cp[K]*ct_psi[K]*pow(Lw,2));
		tD += tdim[K];

		dimrw[K] = (rw/(2*Lw))*(1+sqrt(kh_md[K]/kv_md[K]));//for the transversely isotropic medium
		rwD += dimrw[K];

		Stfst -> SetLaplacePoints(tD);

		void gwkfinal(double *gwk, int nSize);
		
		gwkfinal(gwk,20);	
		
		s= 2*t*PI;

		pD[t] = (2.0*gwk[t]*rwD)/s;	

		dimpress[t] = Stfst -> InverseTransform(pD,tD);		
	}
}

The function which contains code for writing my output file is:
Code:
//Code 2
void CKuchukDlg::OnAnalyze() 
{
	// TODO: Add your control notification handler code here
	// let maximum number of layers = 100: this value can be modified.
	int num_layers = 100;
       int i = 0; // index to count what line is being read;
	extern int K; // K = source layer number
	double H_ft[100],kh_md[100], kv_md[100],visc_cp[100], por[100], ct_psi[100];

	char line[100];


	ifstream inputdeck;
	inputdeck.open("input.txt", ios::in);

	if (inputdeck.fail())
	{
		//cout<<"Error With Files!";
		AfxMessageBox("File Read Error!", MB_OKCANCEL|MB_ICONSTOP);
	}

	else
	{
		//CAN ONE USE SkipComment() for these?
            inputdeck.ignore(60,'\n');
		inputdeck.ignore(60,'\n');

		while (i<=K && inputdeck.getline(line,100))
		{
		       inputdeck>>H_ft[i]>>kh_md[i]>>kv_md[i]>>visc_cp[i]>>por[i]>>ct_psi[i];
			i++;

		} /* while block */
	}

	ofstream outputdeck;
	outputdeck.open("output.txt", ios::out);

	/*code to test that inputdeck.ignore actually works

	outputdeck<<inputdeck.rdbuf(); --> it does! the 1st 2 lines are skipped*/

	outputdeck<<"Pressure\n";

	extern double pD[20];//from code 1
	extern void dimpress(double *pD,int nSize);

	outputdeck<<dimpress(pD,20)<<"\n";//ERROR C2679:binary '<<'no operator defined, which takes a righ-hand operand of type 'void' (or there is no acceptable conversion)

	outputdeck.close();	

	AfxMessageBox("Output file Generated!!", MB_ICONINFORMATION|MB_OK);

}

I don't know why I have this error. Is the problem with code 2? or with the way I called the function in "outputdeck"?
 
No need to read all these codes:
1. In the 1st loop local int K is uninitialized but is assigned to (what for?).
2.
Code:
double tdim[1],...
What for an array with one element? The next using of tdim statement:
Code:
tdim[K] = ...
But K has undefined value in this moment...
 
dimpress() doesn't return anything, so why are you adding it to the outputdeck stream?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top