C++ loop problem

C++ loop problem

Page 1 of 1

4 Replies - 2567 Views - Last Post: 16 October 2009 - 03:45 PM Rate Topic: -----

#1 psubill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-September 09

C++ loop problem

Posted 16 October 2009 - 02:26 PM

Need help with this:

How do you break out of a loop with ctrl Z, being entered by user

This post has been edited by psubill: 16 October 2009 - 08:18 PM

Is This A Good Question/Topic? 0
  • +

Replies To: C++ loop problem

#2 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1270
  • View blog
  • Posts: 4,998
  • Joined: 09-June 09

Re: C++ loop problem

Posted 16 October 2009 - 02:38 PM

Im assuming that your on windows, take a look at GetKeyState()
Was This Post Helpful? 0
  • +
  • -

#3 psubill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-September 09

Re: C++ loop problem

Posted 16 October 2009 - 02:44 PM

View PostImaSexy, on 16 Oct, 2009 - 01:38 PM, said:

Im assuming that your on windows, take a look at GetKeyState()


Yes using windows vista and visual c++ 2008 express edition, what is GetKeyState()????

This post has been edited by psubill: 16 October 2009 - 02:44 PM

Was This Post Helpful? 0
  • +
  • -

#4 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1270
  • View blog
  • Posts: 4,998
  • Joined: 09-June 09

Re: C++ loop problem

Posted 16 October 2009 - 03:11 PM

do you want to enter the string control z ?? Im think you would like to press control z on the keyboard to break out of the loop,

I dont know the value for Z but his is for control - F8

example
BOOL bCtl = GetKeyState(VK_CONTROL)<0;
   BOOL bF8  = GetKeyState(VK_F8)<0;
   if (bCtl && bF8) 
   {
	  break;
   ]


Was This Post Helpful? 0
  • +
  • -

#5 psubill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-September 09

Re: C++ loop problem

Posted 16 October 2009 - 03:45 PM

I see what your saying, But no! I am in beginner C++ just started , this is a dos type screen and asks the user to enter numbers as many as they like then physically press the ctrl key and z , the program is supposed to respond by breaking out of the loop and add up some of the numbers entered ect...

The point is I need a loop to allow the cin >> input; to keep looping allowing the user to keep entering, then when they ctrl z, the loop breaks internally and first number and last number are subtracted to get the difference and display on screen, then display the average and also if they enter a number out of the range it responds with a message " ignore input". Phewww! But I am only like 5 weeks into the class.

View PostImaSexy, on 16 Oct, 2009 - 02:11 PM, said:

do you want to enter the string control z ?? Im think you would like to press control z on the keyboard to break out of the loop,

I dont know the value for Z but his is for control - F8

example
BOOL bCtl = GetKeyState(VK_CONTROL)<0;
   BOOL bF8  = GetKeyState(VK_F8)<0;
   if (bCtl && bF8) 
   {
	  break;
   ]


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1