2,025 Topics
![]() | |
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 … | |
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 … | |
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... :) … | |
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 … | |
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() << ")" << … | |
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 … | |
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> … | |
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 … | |
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 … | |
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 … | |
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> … | |
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 … | |
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 … | |
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> … | |
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 … | |
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; … | |
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 … | |
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 … | |
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 … | |
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? | |
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 = … | |
![]() | 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 … |
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); … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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; … | |
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 … | |
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 … | |
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 … | |
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 # # … | |
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 … | |
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 … | |
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 … | |
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 … | |
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* … | |
[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 … | |
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> … | |
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 … | |
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 … | |
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 … | |
[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 … | |
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 … | |
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 | |
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 … | |
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 … | |
-------------------------------------------------------------------------------- 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 … |
The End.