Help - Search - Members - Calendar
Full Version: Vim
BleepingComputer.com > Software > Programming
   
gnrrocks220
First, does endl; clear the vim buffer?

If so is there a way to force the buffer to be cleared without using an endl;?

I have a series of cout statements with a sleep (2) before each one. When I run it, it adds all of the sleep commands up and prints all the couts. None of the couts have endl;s because I need them all on the same line.

Help?
DarkRaika
Alright, first off I am going with some assumptions even thought I usually don't do this and I"m going to say:
  1. Vim is a Text Editor in Linux
  2. Buffer stream is nothing to do with the Vim Editor
I believe part of your confusion is the fact that Vim and the Buffer are 2 seperate parts and have nothing to do with each other directly.

Sounds like your using Vim as an editor which is cool, you could use other editors but it doesn't matter. Sounds like there are possibly 2 things you want to do, 2 parts of code you want to add and I'l explain them:

1. You want to Resorte the Input Stream.

When your buffer stream is broken it returns a boolean saying is it ok? false
Therefore you want to have code that will fix this buffer stream first before you can do anything so the boolean will read, is it ok? true

cin.clear();

This command takes the buffer stream back to a working state.


2. You want to get rid of error characters that are still in the buffer effectively cleaning it to brand new.

cin.ignore(1000,'\n');

this command means ignore up to 1000 characters of the buffer stream or until it reaches a '\n' character.

Any further problems try out this website.

Or you can hunt me down in the BC IRC channel.

DR
Swandog46
If you don't put endl in, all the outputs will be to the same line.
If you are trying to assure that all output buffers are flushed to the screen or the filesystem, use the iostream::flush function:
http://www.cplusplus.com/ref/iostream/ostream/flush.html
gnrrocks220
QUOTE(Swandog46 @ May 27 2006, 05:05 PM) *
If you don't put endl in, all the outputs will be to the same line.
If you are trying to assure that all output buffers are flushed to the screen or the filesystem, use the iostream::flush function:
http://www.cplusplus.com/ref/iostream/ostream/flush.html

Thanks, that was what I needed. smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.