28 Topics

Member Avatar for
Member Avatar for markdean1989

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 …

Member Avatar for markdean1989
0
353
Member Avatar for Vikram Sehgal

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() { …

Member Avatar for deceptikon
0
501
Member Avatar for Elixir42

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 …

Member Avatar for vijayan121
0
4K
Member Avatar for zahid_3

#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")"

Member Avatar for nullptr
0
113
Member Avatar for Sci3nc3F1cti0n

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 …

Member Avatar for Sci3nc3F1cti0n
0
222
Member Avatar for sarah.mathieson.7

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: …

Member Avatar for vmanes
0
3K
Member Avatar for marnun

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 …

Member Avatar for marnun
0
262
Member Avatar for ousaf
Member Avatar for sidvb1

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 …

Member Avatar for triumphost
0
1K
Member Avatar for jakezcop

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 …

Member Avatar for jakezcop
0
1K
Member Avatar for pattmorter

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 …

Member Avatar for pattmorter
0
287
Member Avatar for Ahmed2

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 …

Member Avatar for Ahmed2
0
228
Member Avatar for Ahmed2

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; …

Member Avatar for Ahmed2
0
386
Member Avatar for ThomsonGB

//////////////////////////////////////////////////////////////////////////////////////// // 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 …

Member Avatar for ThomsonGB
0
250
Member Avatar for Assassin7893

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 …

Member Avatar for Assassin7893
0
839
Member Avatar for lmytilin

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> …

Member Avatar for WaltP
0
577
Member Avatar for imgregduh

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;" …

Member Avatar for raptr_dflo
0
217
Member Avatar for ana_1234

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 …

Member Avatar for Narue
0
336
Member Avatar for Rickay

[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; …

Member Avatar for Rickay
0
5K
Member Avatar for fglom

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], …

Member Avatar for fglom
0
163
Member Avatar for flowerzink

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 …

Member Avatar for Ancient Dragon
0
162
Member Avatar for llamaboy

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()) { …

Member Avatar for llamaboy
0
3K
Member Avatar for puretnaant

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. …

Member Avatar for misfit956
0
145
Member Avatar for globberbob

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 …

Member Avatar for globberbob
0
311
Member Avatar for fire_

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) { …

Member Avatar for Kanoisa
0
150
Member Avatar for Rickay

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" << …

Member Avatar for Ancient Dragon
0
140
Member Avatar for atman

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 …

Member Avatar for StuXYZ
0
113
Member Avatar for DarthPJB

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 …

Member Avatar for DarthPJB
0
294

The End.