46 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 Auroch

Hello everybody! I'm trying to count the number of occurrences of each word in a text file. Problem situation requires to realize menu using "switch" statement (If file exist or not). There are following errors in my program ("case b" and "default" is not working): **[C++ Error] 03_int.cpp(61): E2126 Case …

Member Avatar for Auroch
0
965
Member Avatar for Emma_3

I'm trying to store the contents of a file containing names of herbs and spices (items) in a 2D array called PantryContents. Then I'm trying to add an item to that array. It seems like only one item is being stored at a time, but the output is correct but …

Member Avatar for Emma_3
0
260
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 CreatorZeus

I'm having a simple i/o with file problem. I have the name coming from a string but it just wont open at all. Incoming code: string notename[] = {"NULL","empty"}; ifstream readnote; readnote.open(notename[x].c_str(),ios::in|ios::out); if(!readnote) { cout << "Read Error"; } its prolly something small but i keep getting the error, can …

Member Avatar for CreatorZeus
0
281
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 mixelplik

Please, I know this is a simple question. I'm copying this code out of my text book, almost ver-mother#&$(ing-batm And it mother#&$(ing refueses, REFUSES to open the mother#&$(ing file and write to the mother#&$(ing array. WTF - Sorry for the language, but this is so stupid and silly and I …

Member Avatar for mixelplik
0
188
Member Avatar for nah094020

So i just started my project on a cpu sim , but right of the bat i ran into a problem #include <cstdlib> #include <fstream> #include <iostream> using namespace std; /* * */ int main(int argc, char** argv) { return 0; } void cpu() { } void memory() { int …

Member Avatar for nah094020
0
494
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 Youler

Hi everyone, First post here so feel free to school me if my etiquette needs it. I'm reading a very long string of data (genome stuff AT TT GT AA AG AA ... etc) and comparing it using hamming distance with a similar string. (Naively checking for similarity entry by …

Member Avatar for Lucaci Andrew
0
152
Member Avatar for Youler

Consider the following. I have a text file with 5 rows of 5 characters each. I want to read in a line and then compare it to all the other lines. I create 2 ifstream objects pointing to the same file, first and second. first reads in the first line. …

Member Avatar for Youler
0
127
Member Avatar for Gsterminator

So here is my problem. My program's goal is to to find the shortest path for a maze in a text file. User inputs a string and then the string goes through a function that reads the file into a 2d array. My problem is that I'm seperating the sources …

Member Avatar for Lucaci Andrew
0
245
Member Avatar for s1994

I'm missing something obvious here I think I'm trying to check for the existence of a file, and I hear this is possible with ifstream's .good property. Not even managing to get that far. Forgive me on this, I'm new to C++ Created a new VS console application. I then …

Member Avatar for mLearning
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 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 doomsday1216

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 …

Member Avatar for WaltP
0
167
Member Avatar for christine.j

So, I've been assigned to write a program that reads the wind-tunnel test data, that of which is called the "tunnel.dat" in my program, and then allows the user to enter a flight-path angle. If the angle entered is within the bounds of the data set, the program would need …

Member Avatar for raptr_dflo
0
1K
Member Avatar for Zssffssz

Ok so I want to have the user imput a name of a file to decode it. How would I do that? EX: cin>>fill ifstream in (fill)

Member Avatar for limaulime
0
244
Member Avatar for iamthesgt

In writing a logfile program, I need a function to output the log entries between two dates. I use [ICODE]seekg()[/ICODE] and [ICODE]tellg()[/ICODE] to save the position of the first entry to output and last entry and then go back later to output the data in between. However, [ICODE]seekg()[/ICODE] when told …

Member Avatar for iamthesgt
0
261
Member Avatar for oliviars22

I need to read data from a file into an array of structs. The info is arranged in the file like so... Spear of Extreme Whaling January 1851 Captain Ahab Each member of the array has a name, month, year, and first and last name of creator. This is the …

Member Avatar for thelamb
0
251
Member Avatar for The physicist

Hi all, I'm sure it's an error by me, but I'm having a problem with ifstream inside a loop. The reason for the loop is read in a piece of text from multiple files, and cases within the switch statement change the filename, path is previously declared. The first iteration …

Member Avatar for The physicist
0
2K
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 TheFueley

I'm having trouble figuring out how to use exceptions to check if a file stream was created successfully. I know I can use if statements, but how do I do this using try/catch statements? It compiles successfully but it gives me an error when I supply a non-existent filename as …

Member Avatar for TheFueley
0
8K
Member Avatar for shantanusinghal

[CODE=c] int main(int argc, char *argv[]) { ifstream inHandle; Assembler obj; if(argc!=2) { cout<<"InvalidInput ERROR"; } else { inHandle.open("test.asm"); if(inHandle==0) cout<<"FileNotFound ERROR"; else obj.pass1(inHandle); } inHandle.close(); return 0; } [/CODE] this is my code for the main() function, i have tried entering the filename in every possible format but the …

Member Avatar for Narue
0
616
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 Billybe

Hello I am trying to read from a file. I'm followed a tutorial and had it working perfectly before, and it still does now.. But the problem is that one variable that I'm reading from the file is causing my program to crash. All the other vars I'm reading, are …

Member Avatar for Billybe
0
237
Member Avatar for newbyE

Hi, Please help... I am trying to read in a file in C++ and when I use getline I am not able to read in the last line when the last line in the input file does not have a newline (\n) at the end. How do I do this? …

Member Avatar for newbyE
0
7K
Member Avatar for Armistice

For some reason im getting stuck in a loop after i enter in my "numberinput" i have a mimic case that does the same thing but with characters instead of numbers, and it seems to work perfectly all this is doing is checking to see how many times the user …

Member Avatar for Armistice
0
152

The End.