Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › New to c++, how do I skip a line?
New Posts  All Forums:Forum Nav:

New to c++, how do I skip a line? - Page 2

post #11 of 12
Because "endl" also clears the buffer, I generally use this only at the end of "newline" lines, if that makes sense.

If it was text and then a newline, it'd be:
Code:
cout << "Hello" << endl;

However if you want a series of newlines, it'd be:
Code:
cout << "Hello\n\n\n" << endl;

Or in blocks:
Code:
cout << "Hello\nThere" << endl;

It just doesn't make sense to me, to have a load of endl's in there that continuously clear the buffer. I don't know for sure, but it's probably not very efficient either.

It can be done either way and does not really matter, it's all down to coding style. Read up on what advantages endl offers your code. Try to only clear the buffer at the end of a "section", let's call it.

Edit: I actually only just read through your code, and you're using way too many endl's. Only use it at the end of a block, thus only clearing the buffer once.
Edited by jNSK - 1/31/12 at 7:03pm
Project 4
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 750 Lynnfield @ 4.4 GHz, 1.41v EVGA P55 SLi (132-LF-E655-KR) - A72 BIOS EVGA GeForce GTX 680 4GB G.Skill Ripjaws @ 9-9-9-24, 1.51V 
Hard DriveOptical DriveOSMonitor
80GB Intel X25-M SSD + 500GB WD + 2TB Samsung F3 Samsung Super Writemaster DVD+-R Windows 7 Ultimate Edition Samsung SyncMaster 2433 24" 
KeyboardPowerCaseMouse
Logitech G15 Corsair TX750 750W Corsair Obsidian 800D + Scythe Kaze Master Ace Razer Deathadder Respawn - Black 
Mouse Pad
Steelseries QcK Medium - Black 
  hide details  
Reply
Project 4
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 750 Lynnfield @ 4.4 GHz, 1.41v EVGA P55 SLi (132-LF-E655-KR) - A72 BIOS EVGA GeForce GTX 680 4GB G.Skill Ripjaws @ 9-9-9-24, 1.51V 
Hard DriveOptical DriveOSMonitor
80GB Intel X25-M SSD + 500GB WD + 2TB Samsung F3 Samsung Super Writemaster DVD+-R Windows 7 Ultimate Edition Samsung SyncMaster 2433 24" 
KeyboardPowerCaseMouse
Logitech G15 Corsair TX750 750W Corsair Obsidian 800D + Scythe Kaze Master Ace Razer Deathadder Respawn - Black 
Mouse Pad
Steelseries QcK Medium - Black 
  hide details  
Reply
post #12 of 12
To output everything to 1 decimal point try the command
Code:
cout << setprecision(1) << fixed

Don't forget that you need to include the iomanip library
Code:
#include <iomanip>
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 930 @ 2.8Ghz EVGA x58 SLi LE Radeon HD 5850 G. Skill 6GB DDR3 1600Mhz 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar Black 500gb ASUS Black 24X DVD+R Windows 7 (64-bit) ASUS VH242H Black 23.6" 
KeyboardPowerCaseMouse
Leopold FC200RT/AB Corsair TX650W Lian Li LANCOOL PC-K62 Logitech G500 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 930 @ 2.8Ghz EVGA x58 SLi LE Radeon HD 5850 G. Skill 6GB DDR3 1600Mhz 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar Black 500gb ASUS Black 24X DVD+R Windows 7 (64-bit) ASUS VH242H Black 23.6" 
KeyboardPowerCaseMouse
Leopold FC200RT/AB Corsair TX650W Lian Li LANCOOL PC-K62 Logitech G500 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › New to c++, how do I skip a line?