28 Topics
|
|
I wonder why this program does not do any changes to the text file that I am trying to modify. Scenario: My program uses the Fstream header file, I declared infile as IFSTREAM and outfile as OFSTREAM. I simply want to transfer data from infile to outfile. The data is … |
|
hello again, so i want to make a programme where the file saved is saved with different names at every loop.. like at first loop it will save as file1.txt, 2nd loop file2.txt, so on... so this is my code... #include <iostream> #include <fstream> using namespace std; int main() { … |
|
Dear Kind DaniWebbers, I am trying to overload the fstream operators (ofstream/ifstream), so that I can save a class to a 'Binary' file and also display it with cout. But the ways in which each need to be implemented is different. Please can you show me how to define different … |
|
#Include<fstream> #include<> #include<iostream> #include<string> using namespace std; int main() { string str="time is a great teacher, but unfortunatly" "it kills all its puplis. Berlioz"; ofstream outfile("ali.TXT");//ERROR for(int j=0;j<str.size();j++) outfile.put(str[j]); cout<<"file written\n"; //system("pause"); return 0; } please correct my code"ofstream outfile("ali.txt")" |
|
I'm writing a program that will keep track of every Anime/Manga I watch/read(I'm an avid fan). I'm trying to make a database in order to keep track of all of the titles of the Anime/Manga. My problem is that when i try to add a new title to the existing … |
|
I am trying to write a program that creates a new file every time I use the application. Right now, this is what I am doing: outfile.open("Application.txt"); outfile<<"First Name: "<< firstName <<" "<<"Last Name: "<< lastName<<" "<<"Student Number: "<< studentNumber << endl; outfile<<"Email Address: " << emailAddress <<" "<< "Major: … |
|
It seems I don't understand completely reading from and into files, line by line. Here is my code that is supposed to read lines of two file, into string variables, I assume, and then write them into third file: *line of first file line of second file .... so on … |
|
Can some one briefly tell me about that how to do fileprocessing in c++ |
|
Here I have the classes Logger and Driver. Driver takes the singleton class of Logger, and logs the same statement 10000 times. I want to use this logger, so that it runs in the background and only logs every so often. This will force the program to not use too … |
|
int Finish()//outputs stored values to file { ofstream walletfile; walletfile.open("C:/accounts/wallet.acnt", ios::trunc); walletfile << wallet; walletfile.close(); ofstream accountfile; accountfile.open("C:/accounts/account.acnt", ios::trunc); accountfile << account; accountfile.close(); ofstream savingsfile; savingsfile.open("C:/accounts/savings.acnt", ios::trunc); savingsfile << savings; savingsfile.close(); return 0; } I am a brand new programmer, just learning from the web, i wrote this function as … |
|
a friend asked me to help him with his lab. the lab involves opening a file and adding the numbers in the file together displaying how many even and how many odd numbers there are. I have the file "textinput.txt" in the directory with the .cpp file but when i … |
|
Hi there I've got a problem with functions, where it seems that function call return zero instead of the actual variable value, I will appreciate any help from you guys. I will post the major code parts because the program is big. I get the totallength variable value right but … |
|
Hi there I'm trying to ofstream (output) data to an excel file (csv), and I keep getting this error "file was not declared in this scope". Can you guys help me on this? where is the error? This is the output function, [CODE]void FileOutput() { int t; static float totallength=0; … |
|
//////////////////////////////////////////////////////////////////////////////////////// // In this little project I am trying to learn to get and manipulate data from // a file input using fstream strings I also wanted to use the formating available // with the printf and related string handling methods. I have a question in regards // to the … |
|
Guys, I've been stuck on this for a while now. This is actually one of my assignments, and I'm really lost. This is the assignment: ------------------------------------------------------------------------------------------- You manage a .txt file containing the customer ID number and account balance of the members of a bank. Last week, a computing error … |
|
Hello guys! I have to create a program that prints the last 10 lines of a text or all of it if the number of the lines is <=10. The input will be a file that is unknown to me. This is what I've done so far. [CODE] #include <iostream> … |
|
i have 3 files one main.cpp, functions.cpp, and a header.h im using [CODE]#include<fstream>[/CODE] in the main.cpp and in the functions.cpp but im not sure where to define the ofstream datatype in, so that the main.cpp and the function.cpp share the same ofstream variable. where do i put this "ofstream outf;" … |
|
Hey, Does anyone know how to cpy from one file and redirect to another. I know I have to use the ofstream but I'm stuck. [CODE] while (!in1.eof()) // while not end of input file { in1.getline(current, 100); // read a character from input file out1.in }[/CODE] I'm stuck. I … |
|
[CODE]double speedTest() { double dInitialTime = clock(), dFinalTime = 0; double dRepititions = 99999999; double dResult; cout << "\nCalculating...\n\n"; for(int nCounter = 0; nCounter <= dRepititions; nCounter++) { pow(dRepititions, pow(dRepititions, dRepititions)); } dFinalTime = clock(); dResult = dFinalTime - dInitialTime; ofstream outf("Results.dat", ios::app); outf << dResult << endl; return dResult; … |
|
I'm trying to save everything to a .txt file with a new line after every string, but I can't get it to work for me. I tried using [ICODE]<<endl;[/ICODE] and [ICODE]"\n"[/ICODE] but it all gets written in a single line. So if I enter "John" for [ICODE]first[/ICODE], "Smith" for [ICODE]last[/ICODE], … |
|
Hello guys! I'm having a rather pesky problem working with fstream. I could write, for example: [CODE]fstream file("text.txt");[/CODE] then file should be open in read/write mode. But then if I do the following: [CODE]file << "Some text"; file >> string_var;[/CODE] or in the opposite order, it will only perform the … |
|
Hi I am trying to store an array into a file. I have tried a few ways but I end up with an extra line at the end of the file. The only way I can do this without the line is by writing [code] ofstream myfile("Stock.txt"); if (myfile.is_open()) { … |
|
Hi, I'm having trouble displaying the numbers in the file on the screen. The numbers are in the .data files but i cant get them to display. [CODE]//****************************************************************************** // Exercise: Homework 07 Arrays and pointers // This program reads two sets of integers from the text files A.data and B.data. … |
|
Hi there, im new to the site and am hoping someone out there can help me with my question, im pretty newbie in the world of c++ and programming in general. Im making a program with a menu, you can choose between entering a number yourself to be tested as … |
|
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) { … |
|
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" << … |
|
Hello! I'm new to c++ but I have a problem and desparate for help. I'm trying to store string and integers into a file, but only strings get stored and integers dont. I tried casting,didnt work. Not to convolute you with my code, I came up with this small program … |
|
Howdy, those of you who remember me may be happy to know my 2D game engine was finished and I'm now working on a 3D engine. My engine has been going rather spiffingly well, after some battles with DirectX and OpenGL i managed to get them working side-by-side. Wrote a … |
The End.