Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Vim


  • Please log in to reply
3 replies to this topic

#1 gnrrocks220

gnrrocks220

  • Members
  • 13 posts
  • OFFLINE
  •  
  • Local time:05:08 PM

Posted 23 May 2006 - 03:47 PM

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?

BC AdBot (Login to Remove)

 


m

#2 DarkRaika

DarkRaika

  • Members
  • 58 posts
  • OFFLINE
  •  
  • Location:Not Alpha Centauri
  • Local time:09:08 AM

Posted 26 May 2006 - 07:20 AM

Alright, first off I am going with some assumptions even thought I usually don't do this and I"m going to say:
  • Vim is a Text Editor in Linux
  • 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

Edited by DarkRaika, 26 May 2006 - 07:41 AM.

31337 is a prime number .... 1337 is not .... go figure!


#3 Swandog46

Swandog46

  • Members
  • 134 posts
  • OFFLINE
  •  
  • Local time:06:08 PM

Posted 27 May 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

#4 gnrrocks220

gnrrocks220
  • Topic Starter

  • Members
  • 13 posts
  • OFFLINE
  •  
  • Local time:05:08 PM

Posted 28 May 2006 - 11:59 AM

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. :thumbsup:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users