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.
getline
1,811
questions
0
votes
1
answer
92
views
Is it unsafe to use getline() in c to read from stdin?
I know that an incorrect use of scanf() to read user input can lead to undefined behavior and potentially security holes in a program. I've seen many people suggesting that is better to use fgets() ...
0
votes
1
answer
42
views
How to getline from txt file and check if it is correct with what the user inputed
I am creating a bank application.
So far, I can create an account. After that, it encrypts the data like password and SSN. After that, it takes me to the login function where I have to enter my user ...
1
vote
1
answer
55
views
Combined usage of getline, strcat and realloc functions
Good afternoon everyone! I wrote my implementation of the cat utility in C and ran into some problems. Here's my code:
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#...
0
votes
2
answers
109
views
How to split using getline() in c++
My Input file,
AMZN~Amazon.Com Inc~1402.05~+24.10~+1.75%~4854900~6806813~01/26/18~1523
AAPL~Apple Inc~171.51~+0.40~+0.23%~39128000~6710843~01/26/18~1224`
My code,
#include <iostream>
#...
-1
votes
1
answer
87
views
Why won't my input be displayed from an array of structure?
I am trying to make a program where I can add players' info. I can run the program, but when selecting 'view players record' the nicknames are ommited. Can anyone see the problem here?
#include <...
0
votes
1
answer
117
views
Can't read past EOF in C
Essentially a tail -f implementation: I'm updating a program that works fine on an older system that will continuously read an open file: after EOF, wait for the file to grow and keep reading. On ...
0
votes
1
answer
76
views
eofbit not set with clear in C++98
I have to make a program for homework that reads some user inputs using std::cin and std::getline(), but it is specified that the program should exit only when EXIT is typed.
I am currently trying to ...
0
votes
1
answer
76
views
how to combine files and vector of class type? cpp
create the class Student h which will have the following
characteristics:
● AM: (int)
● Name: (char *)
● Semester: (int)
● Active?: (bool)
Write a function that creates and returns a collection of ...
2
votes
1
answer
98
views
sort out IP addrs from file in C program
So, I have to create a .c file which sorts out IP addresses in ascending order and gives a count to all ip adresses. Considering there is ip.txt file present while has content like below (IP Address ...
0
votes
0
answers
81
views
c++ concurrent getline on ifstream
I want to perform a join on three files and as a last step, I have to compute a sum from a certain column of the joined file.
Let's say this is the part of the code where I read the last file line by ...
1
vote
2
answers
148
views
Using getline() when my line is split into two lines, C++
I am reading from a file, specifically BLS data in text files. Some of the metro names are long and so the data for that city extends to the next line.
A snippet from the file:
999 26380 Houma-...
0
votes
1
answer
60
views
Why does cin.getline() not read the last character when it reads my input and assigns it to a char array?
I am new to C++. I don't understand why the cin.getline() that I use to assign characters to a character array does not return the "correct" number of characters.
For instance, I have:
char ...
1
vote
1
answer
44
views
C++ VSCode Ubuntu Terminal intercepting command line responses
I have a program in Linux C++ in VSCode that I am trying to debug. I am using Boost process::ipstream to send a command line command like "ip -a", then try to use std::getLine() to read the ...
2
votes
1
answer
152
views
getline() reaches end of file when reading UTF-8 emoji character
I'm writing a C++ program that processes large delimited files.
I have a UTF-8 csv file that contains a row with the (emoji?) character 🌟. It looks something like this:
123,"james","...
1
vote
2
answers
56
views
having issue with cin.getline() when working with char data type
If I enter 12345 to arr2, why will the program skip the cin.getline(arr3,6,'#') and just finish?
#include <iostream>
#include <string>
using namespace std;
int main() {
string text;
...