90 Topics
|
|
I'm kind of new to C++ and this forum so forgive me if i look dumb. :icon_cheesygrin: So my program is basically knowing what category is the book inside the "input.txt" using the Dewey Decimal System and displays it in "output.txt It's working fine at the moment. But now it … |
|
ok so what does this do.. 1.) read the text file(most likely a c++ code in text form) line by line and display it line by line... 2.) (as the title says) check for syntax errors. ( only minor ones like missing ";" or a lack of closing braces) soooo..... … |
|
I need a program that opens a sample program and counts the number of reserved words, operands and operators. Operands and operators are easy to distinguish. My problem is how do I determine the reserved words there? One solution I thought of is to create a separate text file that … |
|
I thought about a project idea and I came up with this: 20 questions. I have no clue how to start. I think that a simple knowledge base is necessary, along with a way for it to learn. also, how would it ask questions? it would have to know some … |
|
I already know how to use fstream. I know to save the value variables to a file, and I also know how to make the program display the information in the file, but my problem is that it saves the content of the variable, not the variable itself. Here's what … |
|
I have a function below which is supposed to read from a continuous updating file...by another program. for this reason I used a fileptr int to keep track of the last known good read so this index value is updating correctly but it is not being used by getline. and … |
|
ifstream mystream(file_name); ofstream outputstream(filename, ios::out); do { mystream.getline(line, 100); mystream >> country_name >> happiness_value; total_happiness = total_happiness + happiness_value; count++; outputstream << country_name << " \t \t " << happiness_value << endl; } while (!mystream.eof()); the file ifstream is reading from is a .dat file, in this format: first 1 … |
|
Trying to write a simple program that will read data but keep stumbling upon the fact that I kinda can't limit the amount that is read. I have simple student.dat file which is filled ATM with nothing else but simple string "somethinginside", without quotes. When I do this on each … |
|
Hallo! I've been having some trouble getting a save/load function to work properly. I'm trying to save object and their properties to a file in binary using fstream. And then being able to load the object from the binary file the next time im running my project. Quick breakdown: I … |
|
I need your help... Again... How can i combine reading from file with [iCODE]std::getline(file, std::string);[/iCODE] and [iCODE]UpdateData(FALSE);[/iCODE] ? UpdateData() accepts only CString and getline only std::string, and then i try to use it like that: [CODE]std::string readbuff; int length; std::ifstream file("file.txt"); while(getline(file, str)) { length = str.length(); for(int i=0; i<length; … |
|
Hi im writing a function in a program that lets the user delete a specific record in a file, the user is also able to recover this record. The easiest way i found is when the record is deleted, the record will be set to deleted using bool. Then in … |
|
Hello. I'm writing program wich reads from file line by line and then rewrites everything to other file. This is simplifyied part of code: [CODE]for (int i=0; i<=5;) { getline (file1, str1); /* file1 is file from wich i read and str1 is string*/ file << str1; }[/CODE] No i'm … |
|
Hello. I have some problems. 1.With for cycle. This is my code: [CODE]#include <iostream> #include <fstream> int main () { int i; int i2; char sentence [200]; char repeat; ofstream file ("file.txt", ios::app); for (i=0; i<1;) { cout << "Enter sentence (max. 200 symbols)\n"; cin >> sentence; if (!file) { … |
|
Well, I have a test program, in which I wanted to test if it was possible to open a textfile(text.txt) for input, display it via cout, then passing the object via reference to another function, in it and display the file again(which should already be open,which is the whole point). … |
|
why doesn't this work? [CODE]int main() { fstream file; char output[100], pasword[100]; int a; const string x("Yes"); const string y("No"); string z; char b; cout << "\nEnter correct password to continue: \n" << endl; cin.getline(output, 15); if(output == "file.txt") { cout << "Change password? Type Yes or No. \n" << … |
|
I just started working on a small tool to search for (heavy) text files using Visual C++ with MFC. Because there are a lot of readings, I'm wondering if ifstream of the standard library is better than CFile of MFC? I don't need portability (the program is for Windows Environment), … |
|
Hi guys, I've compiled the code given below which allows the user to enter the address of a text file and then view it(the whole thing). But, as soon as input is taken, "openfile.exe has encountered a problem and needs to close. Send Error Report." When I Press Debug something … |
|
My Question: I have created a text file named it kashif.txt and i have placed this file in the same folder where .exe and .ccp of this program is placed but file is not opening. My code is as under. #include <fstream.h> #include<iostream.h> main() { char name[100]; char sal[100]; char … |
|
I was wondering how to make a program to open a specified file just by entering its location. What command do would i use to open it instead of double clicking on the file. Thanks in advance. |
|
I'm trying to open a file (ifstream object), read from the file, then pass the ifstream object to a function where it will continue reading from the file. Along the way, I want to store the path of the file, and would like to know if there is a way … |
|
int note1in() { system("cls"); string a; ifstream note1 ("note1.txt"); while (!note1.eof() ) { getline (note1, a); cout << "The note reads: " << endl << a << endl << endl; } note1.close(); system("pause"); note1out(); } int note1out() { string a; cout << "Begin re-writing the note... " << endl; getline … |
|
Hey guys, I'm kinda new at C++ and need help writing a program that finds email addresses in text files and stores them in an array. The email addresses are then filtered to make sure there are no duplicates. They are then copied to an output file. The program should … |
|
Let's say there's list of numbers like this saved in a txt file: 4 6 3 4 5 How do I put it into an array? |
|
Hi I'm new to computer programming. 'Im just needing to learn some basic c++ for a larger project. So if someone wouldn't mind guiding me through some basics on i/o streams. I need to able to open a .txt file saved on my c drive and be able to count … |
|
So here is the problem. I have a file that starts with a number, this number says how many entries are in the file (5 means there are 5 names). Each entry takes up two lines in the txt file. First line is the name, the second is a group … |
|
Example of what im trying to do: [U]Definition: test.txt[/U] Apples //line1 Coke //line2 Money/line3 [CODE] #include <fstream> using namespace std; fstream teststream; teststream.open("test.txt"); string line1; string line2; string line3; [/CODE] //I want it so line1 = apples //I wan tit so line2 = coke //I want it so line3 = … |
|
Hi! I'm new to C++, been through the basics, and now I'm attempting to make a small console rpg-game where I want my stats (level, xp and such) to be saved in a file. I've successfully saved them into a txt-file, but how do I open it? I don't need … |
|
i got to do this for my class and i am a total noob! i don't know what to do from this point on. first, i need to use fstream to do this. 3 Tracy 80 91 67 Dana 0 66 44 Scott 50 41 64 Jamie 82 90 87 … |
|
i have this Tracy 80 91 67 and it is read from a file, making it fstream. i want the computer to reconize the numbers and add them and divide them, excluding the name. how do i do it? i can't use fuction so please make it easy. |
|
hi there. say i have a text file. in this text file is all the information i need for my output. the problem is, probably because i'm still very new at this, i don't know how to read this particular text file and output it onto the screen. suppose i … |
The End.