Sponsored Content
Top Forums Programming Read in numbers from console won't stop at newline. Post 303007995 by Corona688 on Friday 24th of November 2017 05:54:16 PM
Old 11-24-2017
The >> operator does not care at all about lines. If you want lines, you'll have to separate it some other way, which is exactly what the stackoverflow code does.

It reads entire lines with getline, then crams the entire line into a stringstream object. A stringstream, unlike standard input, will just hit EOF when it runs out of data instead of waiting for more.
These 2 Users Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script does not stop when doing a read

Hi Folks, I have been trying to create a script wherein after it reads a certain number of data, it will pause and ask the user if he wants to continue or not. However, it seems that when it is supposed to read the user's answer, the script will go into a loop. What is wrong with my script here?... (7 Replies)
Discussion started by: rooseter
7 Replies

2. Shell Programming and Scripting

read from console in ksh

I am stuck with a problem while reading data from a file.. while do read line #do some operations and if some condition is satisfied, ask the user to enter his choice. # using the choice continue operations. done < fileBeingRead.txt The... (4 Replies)
Discussion started by: ajaykumarns
4 Replies

3. Solaris

Red stop signs in Solaris Management Console 2.1

I've installed Solaris 10 (x86 8/07) on a Dell PowerEdge 2950. When I bring up the Solaris Management Console I get red stop sign looking icons on all areas (System Status, System Configuration, Services, Storage, and Devices and hardware) under This computer. Originally nothing was showing up... (1 Reply)
Discussion started by: kayroreality
1 Replies

4. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

5. UNIX for Dummies Questions & Answers

how to stop the message on the console

Hi, Sun Solaris. I am working on the console, I have pulled the network cable out. I am in the process of changing the IP address and few others thing. But this message comes every few seconds. SUNW,hme0: Link Down - cable problem? SUNW,hme0: Link Down - cable problem? It's very... (2 Replies)
Discussion started by: samnyc
2 Replies

6. Shell Programming and Scripting

Null Handling in Until loop. . .loop won't stop

Hi Im running this script, which is supposed to find the max value build some tables and then stop running once all the tables are built. Thing is , it keeps assigning a null value to $h and then $g is null so it keep building tables i.e. testupdateNUL. How can I stop this? Here is what I have: ... (4 Replies)
Discussion started by: brandono66
4 Replies

7. Shell Programming and Scripting

Read Embedded Newline characters with read (builtin) in KSH93

Hi Guys, Happy New Year to you all! I have a requirement to read an embedded new-line using KSH's read builtin. Here is what I am trying to do: run_sql "select guestid, address, email from guest" | while read id addr email do ## Biz logic goes here done I can take care of any... (6 Replies)
Discussion started by: a_programmer
6 Replies

8. Shell Programming and Scripting

Loop to read parameters and stop

Hey guys, How do I make a loop that reads all the parameters en then stop when there are no parameters anymore ? Something that gives an output like this: ./Script.sh parameter1 parameter2 parameter3 parameter = parameter1 parameter = parameter2 parameter = parameter3 Thanks a lot,... (5 Replies)
Discussion started by: Miki1579
5 Replies

9. HP-UX

CDE Login on console won't use keyboard

Hi all, I'm installing a HP r2660 machine with HP-UX 11.23 (this version fixed by customer's product) and I've troubles using the VGA console as workstation display. At first it worked just as TEXT console, then I fixed /etc/dt/config/Xservers and now I've the CDE prompt for login. ... (5 Replies)
Discussion started by: larry100
5 Replies

10. Shell Programming and Scripting

While read won't run keyboard function

I am using while read do/ done to retrieve menu item. Works as advertised, no problem. I am using this hack function "pause" to stop script execution and wait for keyboard "enter" key to continue. Sort of break point function. Also works fine with one exception - it does not work when used... (4 Replies)
Discussion started by: annacreek
4 Replies
FBB::StringLine(3bobcat)					  Line extractor					  FBB::StringLine(3bobcat)

NAME
FBB::StringLine - extracting lines using operator>> SYNOPSIS
#include <bobcat/stringline> DESCRIPTION
The standard operator>>(std::istream &, std::string &) string extracion operator extracts the first `word' from a stream. In cases where the intent it to extract lines from the stream this operator cannot be used, but getline(std::istream &, std::string &) is usually called. However, getline is not called by many tools of generic algorithms, like the istream_iterator. The class (actually: struct) StringLine was simply derived from std::string, and defines its own operator>>, reading the next line from the specified std::istream. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. INHERITS FROM
std::string CONSTRUCTORS
StringLine is an empty shell around std::string. It does not explicitly define constructors. The default and copy constructors are avail- able. OVERLOADED OPERATOR
o std::istream &operator>>(std::istream &in, StringLine &str): The extraction operator returns the next line on in in str, calling getline(std::istream &, std::string &). MEMBER FUNCTIONS
All members of std::string are available, as FBB::StringLine inherits from these classes. EXAMPLE
The following example extracts all lines from std::cin and adds them to the std::vector<std::string> lines: #include <iostream> #include <algorithm> #include <iterator> #include <vector> #include <bobcat/stringline> using namespace std; using namespace FBB; int main() { vector<string> lines; copy( istream_iterator<StringLine>(cin), istream_iterator<StringLine>(), back_inserter(lines) ); } FILES
bobcat/stringline - defines the class interface and operator>>. There are StringLine object files in the Bobcat library, so linking to Bobcat when using StringLine is not necessary. SEE ALSO
bobcat(7) BUGS
None Reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::StringLine(3bobcat)
All times are GMT -4. The time now is 06:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy