2,025 Topics

Member Avatar for
Member Avatar for dansnyderECE

Note that I posted this thread earlier, I'm reposting because the issue has evolved some and I have a clearer idea of what the problem is. I'm trying to resolve a segmentation fault that occurs in the traversal of a string array. My code is doing the following: - open …

Member Avatar for dansnyderECE
0
385
Member Avatar for ahaykal

Hello again, I will go straight to the point. I have two files one that is called student.dat and the other is called grades.dat . Student.dat has the following items in it : 20092112 Anthony Haykal 20084564 John Doe 20075640 James Bond 20045678 Cynthia Smith 20092134 Jennifer Hajj grades.dat has …

Member Avatar for ahaykal
0
107
Member Avatar for dansnyderECE

I'm having an annoying issue with this code. I get a segmentation fault because of the loop wrapped in comments. Any ideas? This is the goal of this program: First I wrote a simple c++ program and compiled a binary file for it. I then use readelf to dump the …

Member Avatar for dansnyderECE
0
185
Member Avatar for ghost_from_sa

Hey guys im having a bit of trouble with bubble sorting an array from a file... Basically what needs to be done is i need to read a text file into a struct array and then copy it into a new file after sorting it by a string field can …

Member Avatar for ghost_from_sa
0
155
Member Avatar for marcoakis

Hello there! I'm new programming in C++, have been learning it for 2-3 months. Now, this uni assignment is working properly, but I'd like to read your advice on how to improve it. All comments are appreciated. Thanks! [CODE] #include <iostream> #include <fstream> #include <string> using namespace std; const int …

Member Avatar for mrnutty
0
79
Member Avatar for Eng.muslima

I have a program code deal with a drug data in pharmacy ...the program is running without syntax error but I have a problem in search code ..it apply search on the first record only but didn't apply on other records..I have tomorrow an exam ..please help me..I'm sorry for …

Member Avatar for Eng.muslima
0
127
Member Avatar for Leppie

Trying to create 20 files using ofstream. I could name each individual file on creation, file01.txt, file02.txt ect but wondered if it was possible to use a string variable in place of say the file name (file01.txt) and then use a loop to create the other files. Does the name …

Member Avatar for Leppie
0
2K
Member Avatar for Excizted

Hello, I have a derived class, that I'm trying to delete. This causes a segmentation error, though. I'm fully aware of the virtual destructor thang, but I'm using it all the way around, and still this issue occurs. I'll post my headers only, please tell if more is required. DataStream.h …

Member Avatar for Excizted
0
3K
Member Avatar for leesho

[CODE]#include<iostream.h> #include<iomanip.h> using namespace std; float number1, number2, number3; void readThreeNumbers(number1, number2, number3); void sortThreeNumbers(number1, number2, number3); void displayNumbers(number1, number2, number3); int main () { readThreeNumbers(number1, number2, number3); sortThreeNumbers(number1, number2, number3); displayNumbers(number1, number2, number3); } void readThreeNumbers(number1, number2, number3) { cout << "Please enter three floating-point numbers, space between them: …

Member Avatar for leesho
0
184
Member Avatar for leesho

[CODE]#include<iostream.h> //is used so it will display output to the user and that input can be read from the keyboard #include<iomanip.h> //is used so that the user can format input using namespace std; int main() { int qty1; cout << "Please enter the quantity of Televisions: "<<endl; cin >> qty1; …

Member Avatar for leesho
0
139
Member Avatar for C#Coder

I'm trying to write a simple file output program for my class. The error I recieve when I try to compile in VS .net 2003 is the following. [I]fatal error C1083: Cannot open include file: 'fstream.h': No such file or directory[/I] The code to my program is extremely straight forward …

Member Avatar for sgtjoebear
0
2K
Member Avatar for leesho

i have an assignment due for my c++ class where we have to input from the keyboard the quantity and input from the keyboard the stock price. so that it outputs as: Stock Item Quantity Unit Price Total Value ---------------------------------------------- Television 5 368.00 1840.00 Video Recorder 8 268.00 2144.00 Camera …

Member Avatar for finito
0
169
Member Avatar for vanalex

Hello everybody! I need to move the get pointer of a text file at the beginning so i wrote in my program the following line (knowing that in a binary file really works): [code=c]ifstream in; in.open("data.txt", ios::in); in.seekg(0, ios_base::beg); [/code] but...in my text file doesn't really work. Is there a …

Member Avatar for vanalex
0
226
Member Avatar for bklearner

I believe that ofstream is for writing into a file and ifstream is for reading from a file. I am trying to write into a file by taking commandline input from the user which is the accept_data() function and and then display all the data from the file that the …

Member Avatar for NathanOliver
0
259
Member Avatar for BaluM

Hello All, Could you please help me on below issue!!!! I am write and read binary file as below, when i write array to file it was writing good but when i read same array i am always loosing last values and below is the code for both operations. Writing …

Member Avatar for BaluM
0
331
Member Avatar for ghost_from_sa

hey guys, im having a slight issue with overwriting a certain record that is selected by a user Basically my application is meant to get user in puts and store them in a file which is refered to when updating, adding a new record, deleting, searching etc here is the …

Member Avatar for nbaztec
0
207
Member Avatar for colmcy1

Hey all, stuck on abit of a problem. I am outputting afew strings to a text file. However when I check the text file it has been automatically split into 2 lines. Is there anyway to force the output to remain in one line or what is the reason for …

Member Avatar for colmcy1
0
82
Member Avatar for goulda660

I'm haveing trouble with this program I don't know what the problem is because my compiler says that their isn't one but the console says their is but it wont give me lines my code is very long too. [ICODE] #include <iostream> #include <fstream> #include <vector> #include "Clear.h" namespace fun{ …

Member Avatar for goulda660
0
212
Member Avatar for corby

hey guys/gals. how do i save to a file the data that is printed by this program i wrote. I have the code to do this in the createFile function but i am unsure in how to output what was printed. Any suggestions? [CODE]//class member functions #include "experiment.h" Experiment::Experiment() { …

Member Avatar for hnizamoglu
0
141
Member Avatar for theABCasian

trying to figure out the reason for memory loss any ideas would be helpful requirements should be done however i need a working file for turn in thanks for help. leak seems to be around line 59-61 i think in demo.cpp Demo.cpp [CODE] /* File Name: Demo.cpp Chapter No. 15 …

Member Avatar for Ketsuekiame
0
268
Member Avatar for manvis2484

I can compile and run the program, but cannot output the text file and print the member list result. Anyone can advice the solution? Thanks. 1. Add new member information 2. Print member list 3. Exit #include<iostream.h> #include<fstream.h> #include<dos.h> #include<conio.h> #include<stdlib.h> #include<stdio.h> #include<string.h> #include<iomanip.h> struct student { char Stdid[7]; char …

Member Avatar for Ancient Dragon
0
243
Member Avatar for triumphost

Ok here is what I want... I want to read the Dictionary file, and output its contents into the dynamic-text.dat file... But it reads the dictionary file and it will not write to the dynamic-text.dat file and I have no clue why... what am i doing wrong.. when I split …

Member Avatar for triumphost
0
343
Member Avatar for brightsolar

Hi everybody have not posted in a while. In all truth i am stuck but very close to finding the collision answer. Note 1 (Most of this skelton was premade for the assignment). Some variables i don;t even know what they do like Vy1. Incx, Incy. Stuff like the file …

Member Avatar for 0x69
0
205
Member Avatar for dchunt

It takes a long time for my comp to execute this simple loop. Now the final do while gives me the problem,even if i use if statement,it takes about 10 secs before displaying the result,which is quite ridiculous. [CODE] int counters[255] = {0}; ifstream in("ut2.txt", ios::binary); unsigned char c; while( …

Member Avatar for finito
0
109
Member Avatar for close_encounter

I'm stuck trying to figure this out. I know I'm going to need a counter I just don't know where or how to implement it. I'm reading from a .dat file. The contents of the file look like this. google.com 760000 250 yahoo.com 340000 170 daniweb.com 230000 125 etc. I …

Member Avatar for Fbody
0
133
Member Avatar for choragos

Hello all. I'm almost certain this question has been posted before, but I couldn't find it--I apologize if it's a repeat. Anyway, I'm having a peculiar problem using getline when reading to a file. I know exactly how the file will be formatted, except the presence of comments at the …

Member Avatar for choragos
0
349
Member Avatar for Robert1995

Heya , I was thinking of making a site opener application :). But I had a lots of problems . The next problem is facing this , it just crashes.:( [B]What do I want my program to do ?[/B] I want to assign a nickname for each of my favorite …

Member Avatar for Robert1995
0
206
Member Avatar for VilePlecenta

When I included a dll file into my project, I used: [CODE] HMODULE g_hModule = GetModuleHandle( 0 ); HRSRC hRes = FindResource( g_hModule, MAKEINTRESOURCE( ID_DLL_MYDLL ), "ID_DLL" ); HGLOBAL hResource = LoadResource( g_hModule, hRes ); DWORD iResSize = SizeofResource( g_hModule, hRes ); BYTE* pData = ( BYTE* )LockResource( hResource );[/CODE] …

0
64
Member Avatar for ziyakhan10

the program runs successfully but the final output comes out in the form of an infinite loop...please help [CODE] #include<iostream.h> #include<fstream.h> #include<conio.h> #include<stdio.h> struct emp { int eno; char name[20],desig[20]; float sal; }e; void main() { clrscr(); ofstream f1; f1.open("emp.dat",ios::app|ios::binary); char ch='y'; while(f1) { if(ch=='y'||ch=='Y') { cout<<"Enter the name"<<endl; gets(e.desig); …

Member Avatar for ziyakhan10
0
193
Member Avatar for HoboConductor

Hi I've been working on a pretty basic program, however I've run into a couple of problems that I've been playing around with for about an hour and I just can't figure it out. [CODE]#include <fstream> #include <iostream> #include <iomanip> #include <cstdlib> #include <string.h> using namespace std; const int MAX …

Member Avatar for Fbody
0
114
Member Avatar for Teethous

Hey guys I am having a problem writing to my text file. I notice when the data is written some of it comes out as gibberish. Take a look and let me know what I am doing wrong. Thank you. [CODE] #include <iostream> #include <string> #include <fstream> using std::cin; using …

Member Avatar for Fbody
0
165
Member Avatar for Dhanish

hi guys......i need to write a C++ program to allow the user to store new albums in a text file, be ale to view all his records at any time, to delete any particular record in the text file, to search for a particular record n decrement the quantity in …

Member Avatar for Lerner
0
140
Member Avatar for umar__farooq

/*Can anybody help me .... there is a problem when i read from file in an array of objects .. the error states that : Debug assertion failed ! file : dbgheap.c line :1017 Expression : _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) if i ask OS to ignore error it states another error i.e. Debug …

Member Avatar for NathanOliver
0
164
Member Avatar for spdbump08

Hello, I need some help getting my program to read from a text file. Everything seems to be compiling fine but Im getting an error as soon as the program runs because, i believe, the information is not being inputted properly. Thanks for any help! [code] #include <iostream> #include <fstream> …

Member Avatar for WaltP
0
95
Member Avatar for decoy684

Hello everyone, I am starting to run completely out of time on an assignment that is due tomorrow. No I'm not asking for free code here, because I already have it 99% complete. My assignment is to read a text file into an array and bubble sort them from highest …

Member Avatar for rurouni
0
317
Member Avatar for karthz85

[CODE]#include<iostream.h> #include<fstream.h> #include<string.h> #include<stdio.h> class database{ public: virtual double store_data(void); virtual double GetPassingMark(int pass); virtual void display(void); virtual void edit(void); protected: void data(void); //database() //~database() }; double database::store_data(void) { char code[100]; double totalmark,laboratory,exam,assignment,sum_assignment; int i,no_of_parts,a,pass; totalmark=0; ofstream display("D:\\record system.txt"); for(i=0;i<7;i++) { cout<<"=======================================================\n"; cout<<"1.enter the subject code"<<i+1<<"\n"; cin>>code; cout<<"2.Enter no of …

Member Avatar for Nick Evan
-2
95
Member Avatar for Justin9825

[CODE] #include <iostream> #include <fstream> #include <string> #include <cmath> #include <cassert> using namespace std; class Payroll { public: int menu(); int option; int mainMenuOption(); int payrollMenu(); int employeeMenu(); int employeeOption; int payrollOption(); int anotherOption(); int exitOption(); int mainMenuOption; { system("cls"); cout << "\t\t Docket Materials Company\n\n"; cout << "\t\t Main …

Member Avatar for Salem
0
126
Member Avatar for mebob

I am getting an error in Windows Vista that says "Project3.exe has stopped working", and has a bar like a loading a bar, and under it, it says it is looking for a solution. The program is an class assignment that takes a data fiile with information about energy usage …

Member Avatar for mebob
0
161
Member Avatar for LisaJane

Hello, I have an assignment where I have to create a hash table and load 30 part numbers into it- should be a 2-d array...and eventually I have to prompt the user to choose an algorithm and keep track of collisions. But I am starting really small with this and …

Member Avatar for peter_budo
0
398
Member Avatar for karthz85

[CODE]#include<iostream.h> #include<fstream.h> #include<string.h> class database{ public: virtual double store_data(void); virtual void save(ofstream &file); virtual double GetPassingMark(int pass); virtual void display(void); virtual void edit(void); protected: void data(void); //database(){cout<<"constructing";} //~database(){cout<<"destructing";} }; double database::store_data(void) { char code[100]; double totalmark,laboraty,exam,assignment,sum_assignment; int i,no_of_parts,a,pass; totalmark=0; for(i=0;i<7;i++) { cout<<"=======================================================\n"; cout<<"1.enter the subject code"<<i+1<<"\n"; cin>>code; cout<<"2.Enter no of …

Member Avatar for chiwawa10
0
131
Member Avatar for Gauntlet

I have command line c++ project for my final project of my course. I've decided to go a little further than the course intends and write a class for creating an uncompressed bitmap picture file. As an initial exercise I decided to create the 2x2 pixel bitmap example from Wikipedia. …

Member Avatar for Gauntlet
1
141
Member Avatar for MJaske

Hey guys. I have a two part homework assignment. It involves reading a text file, creating a structure, and writing the results into a new text file. I have completed the first program and according to my TA it is 100%. My issue is I ran into a mental block …

Member Avatar for MJaske
0
163
Member Avatar for jprogram

I need to get characters one at a time from an ofstream because I need to pass the characters into a function. This is what I was trying but it says "ofstream has no member named get". Here is the code I am using. [CODE] ofstream outFile("source.txt", ios::out); a1.prepare(inFile2, outFile); …

Member Avatar for vidit_X
0
194
Member Avatar for goulda660

My program keeps giving my undefined references to my vectors and items in namespace fun class driver and i cannot change it I really need help I'm a pretty big noob at programming [CODE] /* * Austin Gould * * main.cpp * main to drivers in fun in the sun …

Member Avatar for goulda660
0
176
Member Avatar for yznk

I am writing a sort program and i am getting the error " error: no matching function for call to 'Object::setdepend(Object*&)' " in this line " graph[i]->setdepend(graph[atoi(buffer.c_str())]); " which is in my read function. I am not sure how to fix this, can anyone help? [CODE] #include <iostream> #include <fstream> …

Member Avatar for Fbody
0
1K
Member Avatar for Dex02

Hello guys I am making a speel check program in Turbo/borland c++ and i have a problem with the libary #include <vector.h>. Is this labary in Turbo/borland c++ difrent or what? Here is the program: [CODE] #include <iostream.h> #include <fstream.h> #include <vector.h> #include <string.h> vector<string> explode( const string &znak, const …

Member Avatar for Dex02
0
139
Member Avatar for timbomo

[QUOTE]in the files in_stream2 and 4 they wont open correctly but the rest of them will and i cant move forward until i fix it. i dont even no where to start when trying to fix it could someone help?[/QUOTE] [CODE]ifstream in_stream; // reads itemlist.txt ofstream out_stream1; // writes in …

Member Avatar for timbomo
0
122
Member Avatar for mebob

Hey, i was wondering if there was a way to output really large decimals, either to a file or to the output stream? because when i do this: [CODE] file << setiosflags(ios::showpoint) << setiosflags(ios::fixed) << setprecision(50); [/CODE] or do that with cout, the program crashes.

Member Avatar for DinoBA
0
106
Member Avatar for atticusr5

Ok so I am a total newbie, and for our last programing assignment in my class we are going over Binary Search Trees. Out assignment is to take an older program and make it into a binary search tree. I am using Visual Studio and I have gotten past all …

Member Avatar for mattjbond
0
1K
Member Avatar for yznk

In my code my "ndeps" is not being declared in my "setdepends" function and i dont know why. Can anyone help me figure out why? [CODE] #include <iostream> #include <fstream> #include <cstdlib> #include <cstring> using namespace std; class Object{ private: Object **depends; int ndepends; public: Object(); char *id; enum Color …

Member Avatar for Stefano Mtangoo
0
192

The End.