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.

C++ Help


  • Please log in to reply
3 replies to this topic

#1 Guest_danbrownlow_*

Guest_danbrownlow_*

  • Guests
  • OFFLINE
  •  

Posted 20 March 2007 - 11:53 AM

Hey, I am using a book called Accelerated C++ to learn c++ and the programs are working fine.. it's just that there executing so fast I can't see the results :'(

Here is the code:
#include <iostream>
#include <string>

int main()
{
	std::cout << "Please enter your name: ";
	std::string name;
	std::cin >> name;
	
	const std::string greeting = "Hello, " + name + "!";
	
	const std::string spaces(greeting.size(), ' ');
	const std::string second = "* " + spaces + "* ";
	
	const std::string first(second.size(), '*');
	
	std::cout << std::endl;
	std::cout << first << std::endl;
	std::cout << second << std::endl;
	std::cout << "* " << greeting << " *" << std::endl;
	std::cout << second << std::endl;
	std::cout << first << std::endl;
	
	return 0;
}

I've tried using std::cin.ignore but didn't have no effect. Any ideas? By the way i'm using Dev-C++ :D

Edited by danbrownlow, 20 March 2007 - 11:53 AM.


BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD

Posted 20 March 2007 - 12:08 PM

Try running the compiled executable from a command line, or introduce a 'timer' into the app that causes a delay before it terminates.

#3 Guest_danbrownlow_*

Guest_danbrownlow_*

  • Guests
  • OFFLINE
  •  

Posted 21 March 2007 - 06:03 AM

I used cin.ignore a before the lines were written and it seems to work fine. I don't know how to use timers lol

#4 IKnew

IKnew

  • Members
  • 46 posts
  • OFFLINE
  •  
  • Local time:07:32 PM

Posted 16 April 2007 - 10:40 PM

use
system("pause");
right before
return 0;

your computer will pause for u




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users