41 Topics

Member Avatar for
Member Avatar for nathan.pavlovsky

Hello programmers! I am having a function that has the user enter a name for an object, check if its valid, and return it if it is. I am getting the input via getline, but it seems that you have to press enter twice to make the input work. Here's …

Member Avatar for nathan.pavlovsky
0
2K
Member Avatar for David W

In the last few days, I have noticed a very old thread ... resurrected ... about a non-standard C getline function. To all who may like a C readLine function ... a C function that reads in a dynamic C string of any length ... a function with a similar …

0
209
Member Avatar for taverasme

Hi all, First time poster here, I've referenced posts here on daniweb in the past and it has always been helpful, thanks! But I can't find the answer to this particular problem here on the forums. I need to write a basic string parser as part of a coding assignment …

Member Avatar for Nikolas9896
0
6K
Member Avatar for pravej

Hi, I have a txt file that contain certain data inside it. Example of the txt file: Name=John Age=20 Address=c-34, Newyork Name=Martin Age=23 Address=123, New Delhi .... .... and so on..... Now I have to process the each line get from the file and put the values into arrays. arr_name, …

Member Avatar for Ancient Dragon
0
6K
Member Avatar for CreatorZeus

int numLines = 0; string unused; while (getline(users, unused)) { ++numLines; } cout << numLines << " Clients Found" << endl; //begin the search string search; string line; while(client.empty()) { cout << "Queue: "; //Display What The User Typed getline(cin,search); //Make it capital transform(search.begin(), search.end(),search.begin(), ::toupper); cout << search << …

Member Avatar for Ancient Dragon
0
225
Member Avatar for CreatorZeus

okay i have a file with data orgainzed like this in a dat file to be read: apple.0.0.end. and i want it to be read by char until it sees "." then print that, then read again repeated until the end of the line. so i can show the data …

Member Avatar for deceptikon
0
253
Member Avatar for breezett93

Hi everyone, I am writing a program that converts numbers to words and vice-versa, like typing on a older cellphone. The user enters as many messages as he wants in numbers and/or text. The first character of the messages indicates what the remaining string is: numbers or letters. I can't …

Member Avatar for tinstaafl
0
221
Member Avatar for Sara Tech

Hello, I need help to read entire string line with white spaces. I tried many ways but they didn't work :| If I remove `cin>> company_name;`the run jumps to `std::cout << "Enter the symbol of the company: ";` without completing reading company_name from the user! AND, If I keep `cin>> …

Member Avatar for NathanOliver
0
2K
Member Avatar for Prysm[VA]

Perhaps this question has been asked or even has a thread written about it so I apologize if it's been asked before however I can't seem to find a solid answer online. I read the article: [Written by Narue](http://www.daniweb.com/software-development/cpp/threads/90228/flushing-the-input-stream) about using getline instead of cin when obtaining input from the …

Member Avatar for Ancient Dragon
0
3K
Member Avatar for serdar.ilarslan

Hey guys i am in trouble about BST Tree exercise.. i need to create an array that can take number of elements user want and the user has to enter integers but the program need to get this number in one line ... Here is code that i already wrote …

Member Avatar for serdar.ilarslan
0
318
Member Avatar for Alexkid

Hi There, I need to re-write any mention of .tellg() in my code as the function is not supported on the desired hardware. I have the following lines of code: getline(file,line); { std::istringstream stream(line); stream >> first >> second >> third >> forth; UINT32 file_pos = stream.tellg(); file_pos++; fifth = …

Member Avatar for vijayan121
0
715
Member Avatar for andigirlsc

I am having trouble getting MS Visual C++ to recognize my input for the 2nd getline I have listed. It already recognizes getline(cin, firstName) and allows for input, but won't recognize the second instance of getline. When the program gets to that line of output, it bunches the next two …

Member Avatar for deceptikon
0
374
Member Avatar for learner_new

#include<iostream> #include<fstream> #include<string.h> using namespace std; int main() { //system("clear"); cout<<"\npls input the file where you want to read the data from\n"; string loc; getline(cin,loc); ifstream g; g.open (loc.c_str(),ios::in); string data; g>>data; cout<<"\n\n\n\n"; cout<<"\nthe data read from the file is\n"; cout<<endl<<data; return 0; } > even if fiole being read …

Member Avatar for learner_new
0
231
Member Avatar for existinglady

excuse me but can someone teach me how to get a string with space example : this author i need to get the codes on how to get that thank you

Member Avatar for Lucaci Andrew
0
404
Member Avatar for Lucaci Andrew

I have this function: void read(){ int id; string desc; string title, type; cout<<"Movie's id: "; cin>>id; cout<<"Movie's title: "; cin>>title; cout<<"Movie's description: "; getline(cin, desc, '\n'); cout<<"Movie's type: "; cin>>type; cout<<"You have typed in: " <<id <<" " <<title <<" " <<desc <<" " <<type <<".\n"; } and my …

Member Avatar for Lucaci Andrew
0
272
Member Avatar for MugANDGlass

[CODE]void Load() { book *newptr,*p,*q; char id [12]; string title; string author; int year; float price; ifstream file1; head = NULL; file1.open("books.txt"); if (file1.fail()) { cout << "Error opening file.\n"; exit(1); } while (!file1.eof()) { newptr = new book; // file1.getline(id,12); getline(file1,title); getline(file1,author); getline(file1,year); file1.getline(price); //copy values from the file …

Member Avatar for Lerner
0
225
Member Avatar for jcAmats

hi! can someone help debug my codes? getline() works properly in my main() but if i'm putting it to another function, it ignores the first getline() w/o entering any words and goes to the 2nd getline. my program works like this: i have a menu() that lets the user to …

Member Avatar for jcAmats
0
363
Member Avatar for doomsday1216

Hi-- I am new to C++ and am having trouble with this program: The objective is to take input from a file and write it to output, using the '|' character as the delimiter, but displaying it using a comma (ex, if line 1 is "1000|6 1 6 5 3 …

Member Avatar for WaltP
0
167
Member Avatar for Arjunah

This is a program which i am making of a quiz in which there are lifelines for helping the user solve his question. this function is to chose from whichever lifeline the user wants to chose. but my problem is that it is not inputing the string i.e not using …

Member Avatar for WaltP
0
177
Member Avatar for Arjunah

This is a part of my quiz program in which i ask the user to input question and 4 options and the correct option after which in new funtion i ask the quiz. but although it is asking me "option-1", its skipping the "Ques-" [CODE]int quizquestion() { cout<<"\nQues- "; cin.getline(stmt,100); …

Member Avatar for Narue
0
245
Member Avatar for ag_17

I was using getline() function and it was getting skipped. I searched through the forum and found the tutorial on how to flush the input stream but there is one thing that is still unclear to me : getline() uses newline character as a delimiter. So when a '\n' is …

Member Avatar for Narue
0
166
Member Avatar for Burn August Red

Hey everyone, I'm new to this site. one of my classmates told me about it so I'm giving it a try. anyway, for my class I need to write a code for a payroll program. so far, this is what I've written... [CODE]//Assignment 4 //Page 218 //Question 7 #include <iostream> …

Member Avatar for WaltP
0
187
Member Avatar for king03

Hi there guys I am having trouble with a particular input in my program. If you will run my program and enter the word "IT" in Enter Course, it loops and jumps to do you wish to return to the main menu. Please use Microsoft Visual C++ 6.0 Professional Edition …

Member Avatar for m4ster_r0shi
0
193
Member Avatar for servooo

Hi, i have a problem with getline function in cpp program on os x Error: main.cpp:158: error: 'getline' was not declared in this scope i read that in os x are some issues with getline() function but i am newbie and i dont know what to do. is possible to …

Member Avatar for gerard4143
0
364
Member Avatar for RyanMcMillan

How Would i be able to check for valid input on cin or getline heres what i have [CODE] #include <iostream> #include <string.h> using namespace std; int main() { string word; getline(cin, word); cout << word; system("PAUSE"); return EXIT_SUCCESS; } [/CODE] what i mean by valid input is either if …

Member Avatar for Fbody
0
533
Member Avatar for Razzo1

Well I am coding a small intermediate program to help me with learning c++ , and i am wondering how to check for blank input to cin >> string heres what i have [CODE]string name; cout << "Enter You're Name: "; getline(cin, name); [/CODE] and if i just hit enter …

Member Avatar for mike_2000_17
0
2K
Member Avatar for normanallen

I am trying to drag a program originally written in Borland C version 3 into the light of the present using Visual C++ 2010. I have a curious, apparently simple, problem. The program read data from a file. I can create a noddy program that opens and reads the contents …

Member Avatar for normanallen
0
210
Member Avatar for Tuloa

I can use the program fine without this code but I need to be able to take a line of text a file and read it into a variable. Here is the code causing the app crash: [CODE] string ReadLine() { getline(file, lineread); if (lineread.find_first_of("WSF_") != string::npos) { return lineread; …

Member Avatar for Tuloa
0
196
Member Avatar for JordanHam

I am using getline to read a CSV file. The line it reads looks something like "1/24/2010 6:19 1/24/2010 6:59 Merrill - Valley Farms yhy 69 Vegetation 55" The getline works but, I need to be able to calculate time days between a date the user inputs and the date …

Member Avatar for JordanHam
0
218
Member Avatar for hmushtaq

Hi, I'm currently a student given the task of programming a RPN calculator using C. The following code is some test code that I made to solve the issue described in the thread title. It calls a custom getline() function(while loop) which is also shown and then should take in …

Member Avatar for hmushtaq
0
159

The End.