C++ Builder

Posted on 2003-10-24
Last Modified: 2010-04-17

I'm a novice.

I want to read two pairs of values from a simple file (that can be positive or negative) to determine which are the lowest and highest. The file is just that, a series of values, however teh first one is an x co-ordinate and the second a y co-ordiante.

I have some code that works for a single value, how do I mod it for two.

  maxheight = 0;
  while (file1>>height){
   if (height>maxheight)

This code extracts one value for height and determines the max value. teh file I am looking at detemines heading.

I know this is scandously overpriced in terms of points, but I need help and we're thick in th UK. And yes, it's a college assignment ........


Question by:madoc
LVL 18

Expert Comment

ID: 9615419
Hi madoc,

so what does you file look like?

<x> <y>


LVL 19

Accepted Solution

Dexstar earned 250 total points
ID: 9615462

> I have some code that works for a single value, how do I mod it for two.

  #include <limits.h>

  int width;

  points = 0;
  maxheight = INT_MIN;
  maxwidth = INT_MIN;
  minheight = INT_MAX;
  minwidth = INT_MAX;
  while ( (file1>>height) && (file1>>width) )
    if ( height > maxheight )
       maxheight = height;

    if ( height < minheight )
       minheight = height;

    if ( width > maxwidth )
       maxwidth = width;

    if ( width < minwidth )
       minwidth = width;

Hope that helps,

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
parentbit challenge 3 74
C Programming - If Statement 8 72
c++ reading data from file into two dimensional array 3 96
This code tracks birthdays 3 60
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now