getline Questions

2

Solved

I was given a homework assignment to generate a txt file containing a random number of lines, each with a random amount of integers, ranging between a minimum value and a maximum value. Lots of ran...
Epicurus asked 1/10, 2014 at 4:17

1

Solved

I am trying to read in and then output the contents of a text file with three lines, as follows: Bob Dylan 10 9 John Lennon 8 7 David Bowie 6 5 For each line, I just want to output the line, ...
Cullan asked 24/12, 2013 at 7:47

2

Solved

I'm making a program to make question forms. The questions are saved to a file, and I want to read them and store them in memory (I use a vector for this). My questions have the form: 1 TEXT What ...
Luxor asked 18/11, 2013 at 10:41

3

Solved

I have a code with the following snippet: std::string input; while(std::getline(std::cin, input)) { //some read only processing with input } When I run the program code, I redirect stdin input...
Hardset asked 30/10, 2013 at 3:32

5

What I want is to get the reversed string of current line, I tried to use the rev command in the AWK but cannot get the current result. $ cat myfile.txt abcde $ cat myfile.txt | awk '{cmd="echo "...
Meggs asked 11/3, 2013 at 11:17

1

Solved

I've just came across this bit of code that allows users to input strings in the command prompt. I'm aware of what they do and it's all great. But I have a question in regards to the cin and getlin...
Steve asked 14/9, 2013 at 16:29

2

Solved

I have this code in an Objective-C class (in an Objective-C++ file): +(NSString *)readString { string res; std::getline(cin, res); return [NSString stringWithCString:res.c_str() encoding:NSASCI...
Photoconductivity asked 6/7, 2012 at 2:4

2

Solved

I know the title sounds crazy, but I'm experiencing this firsthand right now and I can't think of any reason why this is failing. I am reading through a file using getline() At the end of the rea...
Quay asked 26/6, 2013 at 1:21

4

Solved

I have this code which is supposed to cout in console the information from the .csv file; while(file.good()) { getline(file, ID, ','); cout << "ID: " << ID << " " ; getline...
Geology asked 8/5, 2013 at 17:24

2

Solved

I'm trying to figure out why this is broke now, because I had it working and I'm not sure what is wrong. I'm trying a simple getline from a file that's been opened, however, the compiler keeps givi...
Intuitional asked 28/4, 2013 at 15:3

1

Solved

Seekg does not seem to work, when I reach EOF in myFile. ifstream myFile("/path/file"); for(int i; i < 10; i++){ myFile.seekg(0);//reset position in myFile while(getline(myFile, line)){ doS...
Suk asked 30/3, 2013 at 16:5

2

I'm using the get line function in C to read through the lines of a file. I want to loop over the function so that I can read through the file n number of times. For some reason though, it only rea...
Deen asked 28/1, 2013 at 21:48

1

I have a problem. I load the whole file and then getline through it to get some info. However in the map format there may be 0 or 20 "lines" with the info. I need to know how to getline through std...
Naji asked 12/12, 2012 at 10:48

1

Solved

Consider the following code: ifstream in; try { in.exceptions ( ifstream::failbit | ifstream::badbit ); in.open(pConfLocation); } catch ( ifstream::failure e ) { throw std::runtime_error("Ca...
Noticeable asked 30/11, 2012 at 18:34

2

Solved

One thing I'm not pretty sure after googling for a while, is the returned string of getline(). Hope to get it confirmed here. std::getline This global version returns a std::string so it's not n...
Jerrine asked 23/11, 2012 at 1:0

1

Solved

Whenever I encounter a substitute character http://en.wikipedia.org/wiki/Substitute_character while reading a file in C++ using getline(), it is interpreted as a EOF so I cannot advance with my rea...
Sunsunbaked asked 18/10, 2012 at 21:17

3

Solved

Possible Duplicate: Need help with getline() getline() is not working, if I use it after some inputs, i.e. #include<iostream> using namespace std; main() { string date,time; ...
Makhachkala asked 2/10, 2012 at 13:33

2

Solved

I have an input file that looks like this (first column is a location number and the second is a count that should increase over time): 1 0 1 2 1 6 1 7 1 7 1 8 1 7 1 7 1 9 1 9 1 10 1 10 1 9 1 10 1...
Cozza asked 28/7, 2012 at 21:37

2

Solved

I'm learning c++ and got the project to send a pascal's triangle to output (after n-rows of calculation)., getting output like this, stored in a stringstream "buffer" 1 1 1 1 2 1 1 3 3 1 But...
Davilman asked 4/5, 2012 at 8:12

1

Solved

I have a theoretical question: 1) How pass a variable to the system of getline ()? awk 'BEGIN{var="ls"; var | getline var; system("echo $var")}' 2) How to assign a variable the output system ("...
Khajeh asked 4/4, 2012 at 9:27

1

Solved

I'm trying to load lines of a text file containing dictionary words into an array object. I want an array to hold all the words that start with "a", another one for "b" ... for all the letters in t...
Juna asked 14/3, 2012 at 23:37

10

Solved

I wanted to compare reading lines of string input from stdin using Python and C++ and was shocked to see my C++ code run an order of magnitude slower than the equivalent Python code. Since my C++ i...
Dustpan asked 21/2, 2012 at 2:17

3

Solved

My code looks like this, string aString; cin >> aString; cout << "This is what cin gets:" << aString << endl; getline(cin, aString); cout << "This is what getline(cin...
Readership asked 23/2, 2012 at 19:5

4

Solved

I have been working on a small exercise for my CIS class and am very confused by the methods C uses to read from a file. All that I really need to do is read through a file line by line and use the...
Knotgrass asked 9/2, 2012 at 5:57

2

Solved

First of all, some background: I'm trying to get in a list of integers from an external file and put them into an array. I am using getline to parse the input file line by line: int lines = 0; siz...
Ferrick asked 7/2, 2012 at 5:35

© 2022 - 2024 — McMap. All rights reserved.