41 Topics
|
|
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 … |
|
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 … |
|
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 … |
|
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, … |
|
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 << … |
|
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 … |
|
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 … |
|
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>> … |
|
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 … |
|
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 … |
|
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 = … |
|
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 … |
|
#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 … |
|
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 |
|
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 … |
|
[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 … |
|
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 … |
|
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 … |
|
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 … |
|
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); … |
|
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 … |
|
|
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> … |
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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; … |
|
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 … |
|
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 … |
The End.