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
1 answer

Reading a Text file with Mixed Input using cin and/or strings

I have just begun to tackle a coding problem I must solve, and am unsure how to get started and accomplish the task. There are multiple text files composed of words. If a word is a number, then that is a student's score on a question, so you add it…
jaredthecoder
  • 315
  • 2
  • 3
  • 8
0
votes
1 answer

How to get input to a string that does not terminate with a space?

#include #include #include #include using namespace std; int main() { vectorGames; vector::iterator iter; string command; string name; cin>>command; if(command=="add"){ cout<<"You…
user3200451
  • 19
  • 1
  • 7
0
votes
1 answer

Using getline on html file

I have this assignment to search for certian info in a html file and put the result into text file. I wanted to do it using getline, but somehow it's not working. I have no problems with using getline on text file so I assumed that you cannot use…
user3178190
0
votes
4 answers

awk remove unwanted records and consolidate multiline fields to one line record in specific order

I have an output file that I am trying to process into a formatted csv for our audit team. I thought I had this mastered until I stumbled across bad data within the output. As such, I want to be able to handle this using awk. MY OUTPUT FILE…
maddop
  • 21
  • 5
0
votes
1 answer

Getline Function Messing with Code

Picking up C++ and having a go at it on OS X 10.9 using XCode 5.0.2 and using Alex Allain as reference. The following code compiles just fine and outputs correctly #include #include using namespace std; int…
0
votes
0 answers

show keywords in a text using VStudio 2012 with c++

I have a problem with my program, which is used to segment a text file to display keywords and store them in another file, assume that "my_text.txt" file contains all the words of my text, separated with a newline, and "empty_words.txt" file…
aminoo
  • 59
  • 4
0
votes
1 answer

Can't delete nextline after getline(cin , (variable)) in a txt file

I am writing a simple program where the user can: A: add a new client B: see list of clients C: delete the database D: delete a client it works well for the most part, the problem is basically that every client also has debt. The debt is shown in…
Bryan Fajardo
  • 161
  • 3
  • 15
0
votes
1 answer

I can't read a single line using getline()

I've got a class: class DataBase{ private: fstream db_file; public: DataBase(){ db_file.open("db.txt", std::ios::in | std::ios::out); } void couteverything(){ string line; if(db_file.good() &&…
tomdavies
  • 1,896
  • 5
  • 22
  • 32
0
votes
0 answers

Input object data from a file in a specific format, add/edit that data, and then output it to the file again

so this is my first time posting a question here so please bear with me. I am studying computer science for my bachelors, and I would like some help. We have created various Classes that are all part of a Roster Management System. I have all the…
0
votes
1 answer

Getline doesn't work for some reason

map - is a file that I opened. line - string The upper part works, but the lower part does not. getline(map, line); getline(ssvalues, values, '|'); // Gets the name of the tileset file tileset.loadFromFile(values.c_str()); …
user3087006
  • 9
  • 1
  • 1
0
votes
1 answer

for loop file data is repeating and skipping other lines c++

I'm almost done with my program that reads in contact data, except when I read it in, certain lines repeat and skip other lines. For example, this is what happens currently: Name: Herb SysAdmin Address: 27 Technology Drive Age: 27 Technology…
0
votes
2 answers

Segmentation Fault (core dump) error

I am writing a program that is intended to count the number of times each word occurs in a text file. I am getting a runtime error that says: Segmentation fault (core dumped). I understand this has to do with trying to access memory that has not…
Atache
  • 169
  • 1
  • 13
0
votes
3 answers

C++ read a metadate file, and process the fields separated by a mix of whitespace and :

I know that there are tons of posts related to reading files in C+, but I still couldn't figure out how to utilize it for my specific purpose. I have a file as below, the first two lines specify a variable number of regions, and from the 3rd line…
Vahid Mirjalili
  • 6,211
  • 15
  • 57
  • 80
0
votes
1 answer

Data validation from getline in C++

I want to ask the user if they want to continue playing another round or quit. If they want to continue I expect them to enter two words in getline, but if they enter quit, I want to break;. Is this possible? Can I check to see if the first letter…
user3027672
  • 11
  • 1
  • 3
0
votes
1 answer

Read float values until ENTER

I have to multiply two polynomials. Input: 2 lines of text each containing 1 to 1000 coefficients (floats) separated by spaces. Output: Result of multiplication. I already found the function that will multiply them, but I have no idea how to read…
user2225809
  • 101
  • 1
  • 2
  • 7