90 Topics

Member Avatar for
Member Avatar for Nether_1

I'm writing a code that will save the username of a user when a button (in this case button1) gets pressed. I save it to a file called info.txt, and i use fstream in order to save it. Currently I'm running into the issue that, while i can open up …

Member Avatar for Nether_1
0
2K
Member Avatar for DS9596

C++: I'm using Microsoft Visual Studio 2012 and I am not sure what to do about these two errors: 2 IntelliSense: identifier "x" is undefined Error 1 error C2065: 'x' : undeclared identifier Prompt: Make program that reads 20 integers, display that array, and find min, max, sum, and avg. …

Member Avatar for ddanbe
0
372
Member Avatar for DS9596

C++: I'm using Microsoft Visual Studio 2012 and I am really confused and am getting errors. Prompt: Make program that reads 20 integers, display that array, and find min, max, sum, and avg. One method named "read from user file" which will ask the user to input a filename and …

Member Avatar for David W
0
608
Member Avatar for tgreiner

I am using fstream to open and close a file. The code works OK, except the the file does not close when I close it the first time. I need to invoke close twice. Any idea why? And, what this is saying about my code that I do not realize?? …

Member Avatar for Moschops
0
750
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 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
515
Member Avatar for jBat

I'm not understanding why i'm able to read from the file but i can't write to it. The fstream is open in both modes. Once the program finishes i haven't changed the content of the file. Thank you in advance. #include <fstream> #include <string> #include <iostream> int main() { std::string …

Member Avatar for jBat
0
769
Member Avatar for Labdabeta

Hello, I have a bug in my program somewhere and I cannot understand why. The program merely prints data from a binary file. Here is the code: #include <iostream> #include <fstream> #include <vector> #include <cstdint> using namespace std; int main(int argc, char *argv[]) { if (argc!=2) { cout<<"Invalid argument count, …

Member Avatar for Labdabeta
0
409
Member Avatar for Labdabeta

Hello, Looking at the standard streams provided by the stl libraries, it seems as though it is impossible to have 1 stream to use for both standard console IO and file/string IO. However, before I give up I would like to ask, is this possible: generic_stream stream; stream=cin; //now I …

Member Avatar for Labdabeta
1
508
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 H_beginner

I m reading data from a text file and then printing it. I am not sure what I am doing wrong but the program prints the last line that it reads twice. void bank_account::viewHistory() { ifstream in_file("bank_transaction_history.txt" , ios::in); if(!in_file) { cout<<"File error \n"; } cout<<"Event"<<setw(15)<<"Amount"<<setw(15)<<"Date"<<setw(20)<<"Current Balance"<<endl; string eve,dat; double …

Member Avatar for deceptikon
0
284
Member Avatar for Cj

For my c++ class i have to write a code that will read integers in to a 2D array from a file and then, using functions/methods, determine if the array is a magic square. My problem is that when i build or compile i get "error C2664: 'DataIn' : cannot …

Member Avatar for richieking
0
993
Member Avatar for Ahsanali1603

I'm tring to make a programe which takes the string from user and save in file(data_file). But I also want to take the .txt file from window and read the file and save in my programe file(data_file). user just give the address of .txt file or any other method in …

Member Avatar for Moschops
0
143
Member Avatar for Ahsanali1603

how I can modify the ofile object of fstream library, and the remaining data remain save as it was. e.g ofile: hello world name class this is the data ofile have and in modification i want to replace the name with "roll number". after modification ofile became ofile: hello world …

Member Avatar for Ahsanali1603
0
122
Member Avatar for furalise

Hi What is the difference between using the **fstream** library to read a file....and using something like a procedure below using the FILE* object? There seems to be two ways to read a file? Thanks /* FEOF example */ #include <stdio.h> int main() { FILE * pFile; char buffer [100]; …

Member Avatar for furalise
0
796
Member Avatar for dirtydit27

Hello, I'm having a little trouble with a some code that I'm writing for homework. Basically, I'm taking two files that contain numbers and merging the contents into another file. The files do not have the same amount of numbers in them (one might contain 7 while the other contains …

Member Avatar for aakash121
0
406
Member Avatar for gobiking

I have been getting used to c++ as I have been trying various scenarious on programs and exand on them with new concepts. This is my first try at exporting data from command line to a text file and the program runs fine with all the calculations. The real issue …

Member Avatar for gobiking
0
242
Member Avatar for josey_matt

Hi, could anybody please tell me what i am doing wrong in this program. The goal is to read the student name and grade from a text file and print it on the screen. This is what i have so far. by the way this is for a school project …

Member Avatar for siddiquedu
0
8K
Member Avatar for Jorox03

I am trying to add a comma to the end of each line ('\n') of a text file til the end of the file is reached. I am opening the file in append mode but am unsure as to how to go about identifying when the end of line is …

Member Avatar for Jorox03
0
3K
Member Avatar for stacey.rae.35

I need help running my program this is what it asks me for "Write a program that asks the user for the name of a text file. The program should display the first 10 lines of the file on the screen. If the file has fewer than 10 lines, the …

Member Avatar for nmakes
0
219
Member Avatar for AmerJamil

When im using fstream.h its giving an error with using namespace std, how ever when i use simple fstream without .h , it is not giving error but not reading the file, How can i use fstream object using fstream.h header file along with using namespace std? Your urgent response …

Member Avatar for deceptikon
0
946
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 TheComputerGuy

I've been reading quite a few threads about creating new files if one doesn't exist...but I need it specifically for windows, in the current directory we are in. I've seen ` ifstream file; file.open("TehLeetFile"); if(!file.is_open()) cout<<"Tehleetness is busted!"; else cout<<"it work!!!!11!!!11!one!"; ` That's just checking to see if the file …

Member Avatar for tinstaafl
0
312
Member Avatar for 123386761

Hello! I'm new here, so correct me if this is the wrong location... but I'm trying to make a program for the Minecraft server I'm on, and it requires that if someone wants to make a map that is used on the server, that there's a .xml file that shows …

Member Avatar for 123386761
0
182
Member Avatar for marnun

> Write an EFFICIENT program that reads in the name of a file containing positive integers that are less than 1,000,000. The program prints out the integers in the file, in the order that they appear, eliminating duplicates. So if the file contained 8 3 1 9 2 8 15 …

Member Avatar for marnun
0
263
Member Avatar for mathias.kastbjerg

Hi - I'm trying to make a databse with the produkts from McDonald, but i can't figure out how. It is supposed to both read and write. Here's what i've made so far... Hope U understand: #include <iostream> #include <fstream> using namespace std; struct Menu { char navn[50]; int pris; …

0
114
Member Avatar for marnun

Here is the exercise: > fileWord > Write the definition of a function named fileWord that receives a string argument that is the name of a file containing words. > > The first time the function is called, it returns the first word of the file whose name it was …

Member Avatar for marnun
0
259
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

The End.