Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #5300

Re: Running a simple c++ program

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeder.erje.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: Running a simple c++ program
Date Sun, 22 May 2011 10:19:28 +1200
Lines 50
Message-ID <93qs3hF1bbU19@mid.individual.net> (permalink)
References <7090140d-28d6-4129-84be-4b6d03cb82c4@y12g2000yqh.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net OBWutbdTPZ8QWUCYWYNaJwmpm8aV/0Pg/Si9mPldODGRnftTQd
Cancel-Lock sha1:aZpMYrBzVO5mDljaDWhhxwmmPYI=
User-Agent Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4
In-Reply-To <7090140d-28d6-4129-84be-4b6d03cb82c4@y12g2000yqh.googlegroups.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:5300

Show key headers only | View raw


On 05/22/11 09:51 AM, lopez wrote:
> Hi,
>
> I tried running the following program using cygwin.
> /** @file list0201.cpp */
> /** Listing 2-1. Reading Test */
> /// Read the program and determine what the program does.
>
> #include<iostream>
> #include<istream>
> #include<limits>
> #include<ostream>
>
> int main()
> {
>      int min(std::numeric_limits<int>::max());
>      int max(std::numeric_limits<int>::min());
>      bool any(false);
>      int x;
>      while (std::cin>>  x)
>      {
>          any = true;
>          if (x<  min)
>              min = x;
>          if (x>  max)
>              max = x;
>      }
>
>      if (x)
>          std::cout<<  "min = "<<  min<<  "\nmax = "<<  max<<  '\n';
> }
>
> the command I used is
>
> g++ list0201.cpp -o list0201 //to compile
>
> and
>
> ../list0201 //to run
>
>
> When I run I am getting a blank screen which does not seem to
> terminate .. Can someone help me

How do you end your input?  You are looping until end of file condition 
on cin, so you need to input an end of file character (^D on a Unix like 
shell).

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Running a simple c++ program lopez <lopezgilsinia@gmail.com> - 2011-05-21 14:51 -0700
  Re: Running a simple c++ program Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-05-22 00:16 +0200
  Re: Running a simple c++ program Ian Collins <ian-news@hotmail.com> - 2011-05-22 10:19 +1200

csiph-web