Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 26th, 2003, 01:12 PM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default cin and unlimited data set size

How can I read in a large set of data (known size by user input at runtime) from cin without using an array. i need to keep the data for comparison later too.

The user will tell me 8 different numbers are to follow.

i need to put these into variables. What is the best way to do this.
Reply With Quote
  #2 (permalink)  
Old August 26th, 2003, 03:21 PM
Authorized User
 
Join Date: Jul 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Using an array is the only way I can see how to accomplish what you want.

Reply With Quote
  #3 (permalink)  
Old August 27th, 2003, 07:51 AM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 I did some more research.

i really do not need to hold all the data in vars, just compare them and hold the smallest and largest ones and keep track of the frequenct of the numbers (look for doubles).

using something like:

double var1= 0, var2= 0
int dup =0
while(cin>>var1){
if (var1 > var2)
   largest = var1
  else largest = var2

if (var1<var2)
  smallest = var1
 else smallest = var2

if (var1 == var2)
 dup++

any suggestions?

Reply With Quote
  #4 (permalink)  
Old October 12th, 2003, 02:06 PM
Authorized User
 
Join Date: Oct 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to yescarthik
Default

if possible declare it as structure and then use cin to input datas


Reply With Quote
  #5 (permalink)  
Old October 13th, 2003, 09:21 AM
Registered User
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to midfinger Send a message via MSN to midfinger
Default

Quote:
quote:Originally posted by yescarthik
 if possible declare it as structure and then use cin to input datas

use a "open array"!!!
just declare // double var[];



midFinger
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Determining Data type with CIN Bourne C++ Programming 2 March 23rd, 2007 05:40 PM
set up image size goldenstate BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 February 15th, 2007 07:37 PM
set image size from attribute bonekrusher XSLT 12 August 10th, 2006 05:49 AM
set size of window on load SoC Javascript How-To 3 September 14th, 2004 03:22 AM
how to set the paper size in javascript sundarisekaran J2EE 1 July 15th, 2004 04:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.