Questions tagged [getline]

A C function that reads an entire line from a stream. It was originally a GNU extension that was standardized in POSIX.1-2008.

1801 questions
0
votes
2 answers

Using getline() to read in lines from a text file and push_back into a vector of objects

I am having issues figuring out how to properly use getline() when it comes to classes and objects. I am needing to read in lines of string type and then add them to the myVec vector using push_back. Here is what I have at the…
Gundown64
  • 103
  • 1
  • 2
  • 9
0
votes
1 answer

std::getline from istream into string[] multiple times blank

So I've got this constructor A::A(std::istream& is) { if (validation(is)) { std::string line[SIZE]; unsigned int i = 0; while((std::getline (is, line[i])&& i < SIZE)) { i++; } .... validation looks like this, it stores…
Benoit
  • 363
  • 6
  • 23
0
votes
3 answers

Read text file between specific lines of text in c++

I am currently working on parsing a file into program memory. The file to parse looks like this: file info second line of file info date # col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 …
Rachael
  • 1,965
  • 4
  • 29
  • 55
0
votes
2 answers

Reading in a file with delimiter and blank lines for hashing program

How do I read in lines from a file and assign specific segments of that line to the information in structs? And how can I stop at a blank line, then continue again until end of file is reached? Background: I am building a program that will take an…
user3399575
  • 57
  • 1
  • 1
  • 7
0
votes
0 answers

getline does not get the whole line

Here is a function of my program. When you use getline(cin,something) it is supposed to get the whole line doesn't it? void readMovieData(MovieData *pMovie, int const size) { string title; string director; int year; int time; for(int i = 0; i <…
user3345335
  • 33
  • 1
  • 1
  • 6
0
votes
1 answer

Extracting Data in different formats in a Text File

I'm having an issue with reading in data and I've been researching it for the past hour to no better conclusion. Pasted below are snippets of my code and the file I'm reading form. The file is opened properly and the struct declarations are also…
James Wilks
  • 740
  • 1
  • 8
  • 20
0
votes
3 answers

C++ store string input as cstring

I am doing an assignment where the first part requires us to prompt the user to enter a string. We need to store this input as a cstring on the heap (not a std::string so we get a better understanding of cstring). I have got something that works…
sion
  • 1,367
  • 6
  • 17
  • 21
0
votes
1 answer

cin.getline() waiting for input

I'm a beginner making a program in Eclipse IDE (C++) and I've got a problem with a small piece of my code. The problem is shown below: char dataArray[100]; cout<<"Please enter a data set string:…
0
votes
2 answers

store every line of input in an array with getline c++

I'm using getline to get input and I want to store every line input to an array so that I can recall specific array content for further processing. Any ideas? Thanks in advance string line; while (true) { getline(cin, line); if…
0
votes
1 answer

Does eof() look at lines or data? C++

Let's say I am trying to read in data line by line from a file called input.txt. There's about 20 lines and each line consists of 3 different data types. If I use this code: while(!file.eof){ ..... } Does this function look at only one data type…
user3367265
  • 41
  • 2
  • 7
0
votes
2 answers

Getting error during runtime related to file input using getline

This is not homework, it is self study. I am getting an unexpected error that is think is the result of getline requesting after the end of file. I though I was checking to see if input was successful with the while(getline(inf,mystring)) but its…
Michael
  • 185
  • 1
  • 10
0
votes
2 answers

Robust numerical user input function but zero not seen as a number

I have made a function for controlling user input so that the user can input anything and including a long string of letters and the function gives out "Incorrect input" and repeats until a number is input. (These are then used for a switch…
user3343772
  • 5
  • 1
  • 4
0
votes
1 answer

using getline to get multiple lines from a file and input them in different arrays

I'm trying to do a simple getline from a filestream and then store the different input into different arrays. The input file is something like this. Course Of Sales Time,Price ($),Volume,Value ($),Condition 10/10/2013 04:57:27…
0
votes
1 answer

Having trouble with reading from file

Okay, so i am supposed to read an entire line of a file and then go through and individually separate each piece into the correct grouping. Here is the code that i have written so far. while(!inFile.getline(largeString, LINE_SIZE, '\n').eof() &&…
0
votes
2 answers

getline undefined..... reading multiple lines

i have spent hours trying to get this to work and have been all over your website and nothing is working for me..... basically i am working on a banking system for an assignment and this is the final thing that i need to do in order to complete my…