From: Chong Kai Xiong Newsgroups: comp.os.msdos.djgpp Subject: Re: Strange output formatting! Date: Mon, 03 May 1999 19:19:46 +0800 Organization: Singapore Telecommunications Ltd Lines: 28 Message-ID: <372D8652.5D542B5C@yahoo.com> References: NNTP-Posting-Host: as002808.singnet.com.sg Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04 [en] (Win95; I) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Actually, there's nothing wrong with the output, at least it did what you specified. What you got has to do with the way output streams (ostreams) work...when you write cout << "Some box data is " << get_volume(x, y, z) << "\n"; it actually translates to: int Temp = get_volume(x, y, z); cout << "Some box data is "; cout << Temp << "\n"; Can't really phrase the explanation but here goes my bad English =) : what really happens is that the string "Some box data" is first fed into a output stream. Next the program calls get_volume() to obtain the result value to output which is then appended onto the stream. Next, "\n" is added. The data stream is then directed to 'cout' which starts printing it character by character to screen from the current cursor position. printf() outputs directly to screen and does not affect the stream, which is why you didn't get the dimensions printed in the correct position. The function was called first before the stream was outputted to screen, so the dimensions appeared in front instead. See my point? I hope my lengthy explanation helped... =) Have a nice day... Descender