2,025 Topics

Member Avatar for
Member Avatar for Chumpcash

Hey, I really need some help fixing the errors in this source file! I honestly don't know how to fix some of the errors. This assignment has to be submitted it 2 days. I've looked for the missing sytax errors and the other ones but i just cant seem to …

Member Avatar for Yiuca
0
176
Member Avatar for CppFTW

Hi, why isn't this code is copying the file a.txt correctly? [CODE]int main() { ifstream input("C://Users//Me//Desktop//a.txt"); input.seekg (0, ios::end); int length = input.tellg(); input.seekg (0, ios::beg); while(true) { char* buffer = new char[length]; input.read(buffer, length); ofstream output("C://Users//Me//Desktop//b.txt"); output.write(buffer, length); break; } return 0; }[/CODE] I attached a.txt and b.txt in …

Member Avatar for CppFTW
0
146
Member Avatar for defender_

I am using this code for simply reading from a text file but i want to put file pointer at the begining again when it reaches to the end of file. But my code below is not working. u can ignore extra bits of my code... like header files... :) …

Member Avatar for ArkM
0
108
Member Avatar for OffbeatPatriot

I've tried several times now to write my own neural network class and I think this is the closest I've gotten, the network seems to run properly but it doesn't seem to learn correctly. I'm trying to make it approximate exclusive or but it seems to be only capable of …

Member Avatar for OffbeatPatriot
0
152
Member Avatar for ttqtrang146

I've got code sections which write and read binary files. But when I print data reading from file. It appears unnecessary characters. [code=cplusplus] int WriteFile(const char* file_name) { fstream file(file_name,ios.out|ios.binary); if(file.is_open()) { string data_block="I don't understand!\nAdd one line"; file.write(data_block.c_str(),data_block.length()); file.close(); cout << data_block << "(" << data_block.length() << ")" << …

Member Avatar for ttqtrang146
0
182
Member Avatar for kesh1000

dear people recently i have been given with this assignment where i have to read from a txt file and then print out the following. the full class list. the class list sorted by gpa the class list sorted by name initial the user enters the class average gpa. i …

Member Avatar for Ancient Dragon
0
104
Member Avatar for brightsolar

my code so far...... [code=cplusplus] // ProjectDevelopment.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> // This libary allows standard input and output operations. #include <string> // strings are used as tempory storage - for the input to a text based file #include <vector> …

Member Avatar for brightsolar
0
238
Member Avatar for lucky_multani

Ok what i'm trying to do in this program is first create an empty binary file of size 31 records. Records includes studid & gpa. and then I insert valid record into the binary file with h(k) = key% 29..and then read this binary file sequentially and write the records …

Member Avatar for Ancient Dragon
0
97
Member Avatar for Clockowl

Hey guys, Below code isn't working as I expect it to do. I expect it to read all params when 6 are given, buuuuuuuuuuuut it only reads one, the rest remains zero. It does enter the case, but the stringstream buf seems empty. What am I doing wrong? [code=cpp] #include …

Member Avatar for Clockowl
0
167
Member Avatar for real_castilla

hi all, I have a binary file, then I try to read them and show the value to the screen, but what I got is always -13108. I don't know why. Here is my code [code] #include <iostream> #include <fstream> using namespace std; void main() { std::fstream f_in, f_out; short …

Member Avatar for real_castilla
0
135
Member Avatar for vishy_85

hello all , im trying to read a text file and display its contents. While i got the code running and the output was displayed perfectly for sometime , i started getting Abort(core dump) error . Am i missing something here ? im using HP-UX. [code] #include <iostream.h> #include <fstream.h> …

Member Avatar for Stinomus
0
153
Member Avatar for szcfama

WHEN DATA IS READ FROM FILE AND I SELECT DISPLAY ALL IT FIRSTLY DISPLAY THE INFORMATION FROM THE FILE AND FILLS WHATEVER LEFT OUT OF THE10 RECORDS WITH WEIRD SYMBOLS. [CODE=cplusplus] # include <stdio.h> # include <string.h> # include <iostream> # include <fstream> #include <stdlib.h> using namespace std; typedef struct …

Member Avatar for amrith92
0
126
Member Avatar for K'rul

Alright i am trying to read from a file so that it opens into the array temp_array. the idea is to have the data previously added to the file open into the array so i can search it and sort it this is giving me alot of stress it is …

Member Avatar for szcfama
0
241
Member Avatar for szcfama

After adding information, when i choose the option "Display all" it crashes right before it's going to display GPA... can anyone help me...also can anyone help me read from the file into the array... plzz...this is really frustrating...any help greatly appreciated. [code=cplusplus]# include <stdio.h> # include <string.h> # include <iostream> …

Member Avatar for Daiva
0
173
Member Avatar for Generalcrix

I am doing a program on payroll before any deductions are made but i seem to be encountering some problems. Here is the program [code=cplusplus] # include <stdio.h> # include <string.h> # include <stdlib.h> # include <fstream> # include <iostream> # include <cstring> using namespace std; typedef struct { char …

Member Avatar for Salem
0
141
Member Avatar for K'rul

Can anyone help me fix these?Program displaying and writing symbols to my file... And also after calculating GPA , when choose function read or display all it is illustrated as null....help plz [code=cplusplus] # include <stdio.h> # include <string.h> # include <iostream> # include <fstream> #include <stdlib.h> using namespace std; …

Member Avatar for K'rul
0
101
Member Avatar for azjherben

I was told olny the computer / home that the "host program" was in needed to be port forwarded, but you need port forwarding just to use the client too. Base code for client program: [code] //Main.cpp #include <iostream> #include "Socket.h" #include <fstream> #include <string> using namespace std; string getcot(char …

Member Avatar for azjherben
0
102
Member Avatar for monkey_king

I'm trying to get myself acquainted with memory allocation and deallocation while writing a program that will actually be usefull for me. The program is a simple datareader, that tries to read a matrix from file. The "main" program which works is 'int get_lex(char *in,char *delims,char ***returnvals)' This will essential …

Member Avatar for monkey_king
0
131
Member Avatar for stardustmeri

I am new to ctt programming and I am having some problems trying to get an understanding of what this programming is all about. The following program is the code. Note that in the program we must include the requirement that the program end if the user inputs an invalid …

Member Avatar for _Nestor
0
138
Member Avatar for Usura

anyone know why this wont work? [CODE] fstream f; f.open("a.dat", ios::in | ios::out | ios::binary); [/CODE] it doesnt create a.dat... also how would i switch f from read state to write state?

Member Avatar for amrith92
0
117
Member Avatar for nanchuangyeyu

Hi, What I actually want to do is really quite simple,that is, convert all the data(of short type)in a file to their abstract values respectively.But I did not accomplish it. Here my code is listed:[CODE] #include <iostream> #include <cmath> #include <fstream> using namespace std; int main() { char *in_name = …

Member Avatar for ArkM
0
133
Member Avatar for nalasimbha

Hi, I am trying to extract data from a text file into an array or even a vector. The example data in the file "data.txt" is in the following manner Home number = 123456 Mobile number = 789012 Office number = 567987 Balance = 46.56 ... ... ... I want …

Member Avatar for Lerner
0
240
Member Avatar for Deme

Well, once again, hello. I'm trying to figure out why when i use 2 cin.getlines after eachother it skips one of them and I cant use it. Take a look if you will: [CODE] void Join() { char* Username = new char[255]; char* Password = new char[255]; ofstream DataBase("DataBase.txt", ios::app); …

Member Avatar for Deme
0
212
Member Avatar for kenji

Hello, This is for an assignment I have to do, I have completed most of it just can't get one part to work correctly. The assignment is: The TextFieldLoader class will have only one constructor and MUST accept the following parameters only: 1. filename (const char *) that will be …

Member Avatar for tux4life
0
100
Member Avatar for nanchuangyeyu

Hi, I am writing some code to model the neighborhood of an element in an 2D mathematic matrix(using 2D vector) ,e.g. to an element indexed by vec_2d[x][y], I want to present its neighborhood in form of a vector which is composed of vec_2d[x][y-1],vec_2d[x-1][y-1],vec_2d[x-1][y] and vec_2d[x-1][y+1]. And following my code is …

Member Avatar for Nick Evan
0
829
Member Avatar for Deme

Alright, so i'm trying to make a type of database using file i/o where you type in a username and password and it writes it to database.txt... The issue is, i'm trying to find a correct and clean way of reading, or 'searching' for the username and password and compares …

Member Avatar for valtikz
0
988
Member Avatar for Playtner

Hi, I've been trying to create program that can access a binary file with a vector in it without first saving it to the file. If I just try to read from the file without saving something, the vector will have information in it but when I output it to …

Member Avatar for Playtner
0
93
Member Avatar for Jyncus

I'm attempting to read in various numbers and chars from a text file using ifstream. I've read through a lot of C++ File IO and can't see why my two int variables, numOfVars and numOfCNFs, aren't getting assigned in the Parser::BuildCQF() method. The code below shows my Parser.h, Parser.cpp, the …

Member Avatar for MrSpigot
0
114
Member Avatar for Sam-J

hello everyone i am a fresh man in this site ... and i'm really pleased joining this lovely 'n useful one well .. i made a program in c++ which is all about natural merge sort on files , since i want to sort my file which contains a randomly …

Member Avatar for WaltP
0
407
Member Avatar for nanchuangyeyu

Hi, I have written a 2*3 matrix[1,2,3;4,5,6] to file. And then I tried to read the data back to initialize a 2D C++ vector. The code is as following: [CODE] #include <cmath> #include <string> #include <iostream> #include <sstream> #include <fstream> #include <vector> using namespace std; int main() { ofstream out_file; …

Member Avatar for nanchuangyeyu
0
121
Member Avatar for Duki

So my Data Structures class has finished the book we were using, but we still have a week of school left. My instructor has started going over binary files... only problem is I wasn't there when he went over it. My assignment is to open a binary file, save the …

Member Avatar for vmanes
0
153
Member Avatar for nanchuangyeyu

Hi, I am now writing a simple program for testing file I/O and an advanced vector class. Unfortunately I have encountered some confusing problems. My code is as following: [CODE] #include <cmath> #include <string> #include <iostream> #include <sstream> #include <fstream> using namespace std; class mVect { private: // NO PRIVATE …

Member Avatar for nanchuangyeyu
0
130
Member Avatar for cam875

I am trying to take a a file of fixed size and use seekp to jump to a particular spot in the file, write around 100 bytes or so but only to that part of the file while still keeping the size of the total file the same and not …

Member Avatar for cam875
0
87
Member Avatar for lqdo

hello all, I'm getting some unexpected behavior from the ifstream object when using the open method. im reading the following characters from a text file: [CODE] ############### # #X# # # ### # # ### # # # # # # # ## ## # # # WWWW###WWWW # # …

Member Avatar for NathanOliver
0
131
Member Avatar for saadjaved14

Hey... ok before i start i want to say that i'm not a very good programmer... and i'm new with this... and i got a project that i have to submit in 2 days so i badly need help!! ok the problem is: I'm using binary file handling, a code …

Member Avatar for ArkM
0
107
Member Avatar for sinapse

I have this problem to solve for preparing for the olympiad and i'm not quite fond of the functions so that i want to do it classically but i find it harder.Here it goes: "During a desert operation a group of soldiers were lost from different squads.After the storm passed …

Member Avatar for Salem
0
159
Member Avatar for Lexter25

Can you tell me how to resolve my problem. i can reserve the matrix A and B into file, but how to read , i can't remember...above, shows what i pretend to do.. # include <iostream> # include <fstream> using namespace std; int main() { int matriz[3][3]; int x,i,j;//variables for …

Member Avatar for WaltP
0
289
Member Avatar for strickenUK

The program is suppose to write and then read data from the binary file and use seekg to display specific data depending on what is entered by the user. It displays the correct information when 1 is entered but not 0. Any help would be greatly appreciated. [CODE]#include <iostream> #include …

Member Avatar for strickenUK
0
852
Member Avatar for vishy_85

hello all , im having a problem throwing corba system exception the following is my code [code] #include <createPlan.h> #include <writeLog.h> bool createPlanFunc(const schedule_Mgmt::planData & newPlanData1) ACE_THROW_SPEC (( CORBA::SystemException , schedule_Mgmt::alreadyExists , schedule_Mgmt::unknownErr )) { try { ofstream outfile("/cc/smc3/ss_pool4/elem_level_mgmt/tools/Schedule_Mgmt/Schedule_Mgmt/src/scheduleLog.txt",ios::app); bool repeatdelay_bool; bool notonweekend_bool; bool validity_bool; const char* prepeatdelay; const char* …

0
67
Member Avatar for ankit894u

[CODE]#include <iostream> #include <fstream> using namespace std; void PrintError(fstream&, char, bool&); int Conversion(fstream&, char&, bool&); int main() { fstream InFile; char Bit; int Decimal; bool BadBit = false; //Open file to read InFile.open("f:\\Binary.txt",ios::in); //Read the first bit of the number InFile.get(Bit); //continue reading all numbers till the end of file …

Member Avatar for WaltP
0
146
Member Avatar for boydale1

I keep running into problems with my program to evaluate baseball stats. When I try to INPUT filename I run into glibc and if run TEAM identifier then i get a segmentation fault. The glibc didn't start happening until I put in the PLayerData.clear() statement. [code]int main( ) { vector<Player> …

0
42
Member Avatar for mmeyer49

I'm almost done with my 2D dungeon game, but for some reason i cannot move when my program calls to move i cannot move ever when i set the Vitality to 100 it sets it to 0. When i remove the params and make it so it will move it …

0
73
Member Avatar for guest7

Hi, Following is the function which is giving me a segmentation fault. I do not know what is wrong in this code. I am counting the number of lines in the file. [ICODE] char f11; char c; int f12 = 0; FILE *ilfile; ifstream ficnf; int size_f = 0; int …

Member Avatar for Nick Evan
0
154
Member Avatar for AutoC

Hi, Here's my code [code] #include<iostream> #include<fstream> #include<string.h> #include<math.h> #include<stdlib.h> #include<stdio.h> using namespace std; int cIndex(char *x,char **featlist,int len) { int i; for(i=0;i<len;i++) if(strcmp(x,featlist[i])==0) return i; } int main(int argc,char *argv[]) { std::ifstream featFile(argv[1],ios::in); std::ifstream trainFile(argv[2],ios::in); // std::ofstream svmFile(argv[3],ios::out); char line[20000]; char feat[100]; char **featlist; int i=0,len=0,fl=0,j; char* x; int …

Member Avatar for AutoC
0
146
Member Avatar for ankit894u

[code=cplusplus]#include <iostream> #include <fstream> using namespace std; void PrintError(fstream&, char, bool&); int Conversion(fstream&, char&, bool&); int main() { fstream InFile; char Bit; int Decimal; bool BadBit = false; //Open file to read InFile.open("f:\\Binary.txt",ios::in); //Read the first bit of the number InFile.get(Bit); //continue reading all numbers till the end of file …

Member Avatar for ankit894u
0
117
Member Avatar for orcsoul

I've gotten about 90% of this program done, but I can't seem to figure out how to do one last operation in it that is needed. What I'm having a hard time figuring out, is how to make a total for each person in the file? I'm sure it's deceptively …

Member Avatar for orcsoul
0
122
Member Avatar for guest7

Hi, i wish to know the difference between the following two code? ifstream fin(fname,ios::in); vector<string> temp; while(getline(fin, line) { temp.push_back(line); } and while(!fin.eof()) { getline(fin,line); temp.push_back(line); } thanks

Member Avatar for ArkM
0
113
Member Avatar for ScienceNerd

I’m trying to code a program that displays letters in alphabetical order. It complies but the problem is that when it compiles, the letters [characters] don’t show up. The only thing the text file has is some random letters {A E C B D O). [code=cplusplus] int count(char input_filename[]); void …

Member Avatar for WaltP
0
128
Member Avatar for binamy1

I have been programming a compressor based on lz for my school project.When i used fixed block sizes there were no problems but now when i started using variable block sizes it crashes.The compression takes place without much problem but decompression crashes and debuggers does not report any error. Uncompression …

Member Avatar for binamy1
0
140
Member Avatar for burger87

-------------------------------------------------------------------------------- Hey all. I'm a newbie at C++ and hope that you guys can guide me along. I recently got assigned a project and is needed to code it in C++, which I have almost zero experience with, so bear with me. =) I need to delete 3 log files …

Member Avatar for burger87
0
139

The End.