2,025 Topics
![]() | |
Hi I am new to this forum and to c++.I am having problems reading data from a txt file into a 2d array. The data is in the file like this 1 5 87 3 3 24 2 4 62 4 2 22 I am only suppose to read in … | |
Hi, I need help with something I'm working on. I just want to get a basis to start, but I'm hoping to end up with a system where I can store encrypted output in an outside file. Right now my algorithms are a little elementary to consider even stable, but … | |
Hi, I am in need of some help with a small portion of my program. I have an input file as follows: [CODE]10 9 15 program1 11 1 30 important 12 11 10 junk program 14 15 5 other program 17 6 20 another program[/CODE] I need a function to … | |
Hi I’m getting compile errors in the following code: [code] void Driver::read_data() { ifstream infile("data", ios::in); string name, surname; while (infile >> surname) { infile >> name; Person temp(infile); temp.read_surname(infile); temp.read_name(infile); temp.read_phone(infile); temp.read_age(infile); temp.read_weight(infile); 87 person_map[surname][name] = temp; } } [/code] The errors tell me that 87 driver.cpp instantiated from … | |
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday [code]//ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include <string> using std::string; class ClientData { public: // default ClientData constructor inline ClientData( int = 0, string … | |
Hello Im trying to segment a file. In doing so I need to open/createnew smaller files. The code I have [ initial.open("c:/test.jpg", ios::in|ios::binary); // input output.open("c:/copy.jpg", ios::out|ios::binary); // output] only creates one file output. I would like to have a for loop which creates n file eg text1, text 2, … | |
Hi I used an variable int i; in a faunction block as it is in a code below. [code] #includes.... int i; int function() { while(charbuff[i]!=' ') { ofstream stream("file.lng", ios::app) stream << charbuff[i]; i++; stream.close(); } return 0; } main() { ........... some code function(); /*call function */ cout … | |
I start to write a code for a shell with some basic functions: open files, save files, create files... I try to use the ifstream for opening files. I found the constructor - ifstream openfile("file.txt", ios::in); I try to use this constructor in the way (function openfile()) that I can … | |
i have to make a program for cinema management system. here i include the question and the source code that i've made before. question: ---------------------------------------------------------------------------- [COLOR=black]. Students are required to design a Cinema Management System program that can perform the following functions (this program should depict the online system of … ![]() | |
Hello, ostream - how to insert a line of text instead of overwrite in the beginning of the file? #include <fstream.h> int main() { char fileName[] = "SampleFile"; char buffer[255]; ofstream m_fp; // m_fp.open(fileName, ofstream::ate ); m_fp.open(fileName, ios::in|ios::out); m_fp.seekp(0, ios::beg ); m_fp << "This is the line written to the … | |
Hey Guys and Gals I am new to this site and new to programming. C++ is the first one I am trying to learn. I ran into a problem on one of my assignements. I believe my problem is in the actual calculations. The Bonus part of the program is … | |
Please help a newby trying to code first program. I want to be able to write data to a file, then read from the same file. I can manage this OK, but If I set-up a loop to do the same procedure again I get an error message telling me … | |
hi, well my question may be very basic but can u help me I have a buffer that including my data which is binary data and I want to use the iostream to handle the buffer read/write, seek ... etc, I am using the strstream to do this, by setting … | |
hi, have a little problem using fstream. first here is the code... [code] #include<iostream> #include<fstream> using namespace std; int main() { string word; ofstream outl("biscuit.txt", ios::out); cin>>word; outl<<word; system("pause"); return 0; } [/code] using this, i can type a word into the input screen and it saves whatever word i … | |
<<split from: [thread]42172[/thread]>> [QUOTE=weehoong]Hi there guys! Just want to say these communities are great! i've really benefited alot from the forum and its tutorials. Special thanks to [B]FireNet [/B] and his file handling tutorials. It really helped me alot! Not forgetting, thanks alot to all of the members here too. … | |
I have the following code This is the Point header file [code] #ifndef POINT_H #define POINT_H #include<string> using namespace std; //Class Point represents points in the Cartesian coordinate class Point{ protected: double xCoord, yCoord; //coordinates of the point string name; //name of the point public: Point(); //default constructor Point(double, double, … | |
Hello everyone, I am having some problem in reading the data inputted in a file correctly using linked lists. I think this might be because of having pointer next of type password class. Thanks, comwizz. The code is posted below. You may directly see the section if (reply==3) as that … | |
just wanted to say heya to everyone first, ok im doing a C++ assigment on linked list but im stuck. i need to write a program that reads records from a text file and then stores them in a linked list. i can read the data from a text file … | |
Hi, I am having problems with my problem 4.This is what I have as my code. I have 7 compiler errors in it. I don't know how to put the ATM into my program. My project is due wed night and I am cramming to finish this. But I need … | |
Hi there guys! Just want to say these communities are great! i've really benefited alot from the forum and its tutorials. Special thanks to [B]FireNet [/B] and his file handling tutorials. It really helped me alot! Not forgetting, thanks alot to all of the members here too. :idea: :cheesy: anyway, … | |
Iam Trying to implement a basic text editor in c++. I've used a doubly linked list for storing the typed characters in a line and have implemented another linked list (No 2)to store many such lines for a document... When i try to save the file using list No2,i find … | |
I have been fiddling with these damn loops for hours. I am new to c++ but not too programming. My teacher is absolutely worthless. she refuses to help me and explains things very poorly. I have a 100 % on the assignments in the class and do not wish to … | |
I doing assignment about file processing. It quite hard. 1.Sometimes can open the file sometimes cannot 2.How to overwrite y content in the file? 3. How to add Data into the file? Brief: You know I create the file then when I close the program. After that open again. It … | |
can anybody give me an idea how to sort string in alphabetical order in file.text after user input string and in the file already had a list of string? which is the best,let user input the all string first then sorting it or sorting if after user input the string? … | |
I am using VC++. I want to display to the user all data that is stored in an input file and an output file. My input file contains the following so far but will continue to grow as the user uses it: 100.00 123.45 234.56 212.45 Here is what my … | |
Does anyone know how to get a c++ program to output to a usb printer or at the very least an acrobat distiller? I am trying to use the following: ofstream print; print.open("lpt1:", ios::out); print<<"blah blah blah"; but I guess I have a usb printer and not a lpt1 printer. … | |
I would like to note that this is for John Conway's game of life but I must write it in C++. I am making a 10x10 version of the game and I am using jGRASPto write the code. I am having a problem when it is reading in the starting … | |
Hello, I am working on a server program that deals with opening files, or at least that is all that is relevant for this post. I am using VC++. I use multithreading so that it can be multi-client, of course, but when I try to use this line: [CODE]infile.open(filename, ios::in);[/CODE] … | |
I have made this program which im really certain would work, it compiles with no errors, but runs continuously after getting the name of the output file. The program takes a loads of names each with 12 numbers, gets the name using getline, and puts the numbers into an array. … | |
I have somewhat of a weird problem which probably is caused by my compiler, but when I include <fstream> some of it's members cannot be found back in the std namespace. When i use <fstream.h> these methods are availabe. The methods are ios::nocreate and ios::noreplace, anyone who has had the … | |
Hi guys and girls, im currently struggling trying to work out all this array and file input stuff! I have been going round in circles for the past few hours, reading books and googling everything i could, so now im hoping some of your intelligence will help me :) Basically … | |
hi i want to : 1. view all the books 2. search for a book i have managed to complete part of this . the code is as follow: [CODE] #include <iostream> #include <fstream> #include <assert.h> #include <stdlib.h> using namespace std; const int BOOK_MAX = 5000 ; const int USER_MAX … | |
I have written a program that performs a simple version of Run-Length coding compression on a file. I thought everything worked, but after a closer look at the output from the program, letters after a space are counted 1 too many times. I.e, if the letter 'p' appeared 6 times … | |
Any help would be appreciated, this project is fustrating me. Has to do with PGM image files, but really the problem in my code (I would assume, lies within my pointers and dynamically allocating memory). Any help would be appreciated. Code: (main.cpp) [CODE]#include <cstdlib> #include <iostream> #include <string> using namespace … | |
i have this program trying to read from a file but i keep getting this error message what am i doing i cant figure it out. [code]#include<iostream> #include<cstdlib> #include<cstring> #include"assignment9.h" #include<fstream> using namespace std; const int MAX_LEN = 30; int numofRecords() { int numRecords; cout <<"number of courses to process: … | |
Hello all. I have a small homework problem to write, and I could use a little help, someone to guide me in the right direction. I need to write a program that asks the user to enter the filename, and then enter the string to search in that file. If … | |
I have to develop a C++ program that reads the data records from the input file and stores them in a dynamic array of structs, which should be sized just enough for the problem. (TIP: Your program should first scan the input file to determine the number of records to … | |
I'm a college student in a C++ class. I'm writing a program, and I get the follow error: [I][taz3] 3:36pm ~/c++ > gcc stustats-sjs.cpp -o stustats-sjs.app stustats-sjs.cpp: In function `int main()': stustats-sjs.cpp:64: ANSI C++ forbids using pointer to a function in arithmetic stustats-sjs.cpp:65: ANSI C++ forbids using pointer to a … | |
hello all it is my first time here to post :cheesy: well i hope i'm welcomed here my problem is i want to read binary file and view it on the console two times [CODE] #include<iostream> #include<fstream> using namespace std; class Student { private: char name[20]; char address[80]; int age; … | |
I have the following code: [code] ostream Person::operator<<(ostream& out, const Person& p) { out << "/n*********************************" << endl; out << "Name: " << Person::getName() << endl; out << "Age: " << Person::getAge() << endl; out << "Health: " << Person::getHealthLevel() << "%" << endl; out << "Happiness: " << Person::getHappinessLevel() … | |
I am trying to write a program that will demonstrate the use of functions with a structure. I know a lot of students try to get quick answers, I want to learn, but I am stuck, and could really use some help. I keep getting the following error: C2448: 'salary' … | |
i'm supposed to use nested for loops to estimate the value of e and display the estimation through each run. this is what i got so far, but i found out im not supposed to use setprecision so i've done it wrong but don't know what to do to fix … | |
:rolleyes: Hi. I'm new to this forum and well I'm also new to the programming languages. :) and im taking some programming classes c++) i need help with a program that im working on... I have tried for about two days to see what is the problem but i just … | |
Hello I figured out my other problem, now left with another 2. One which I beleive is a logic error since if I enter A it will output AA but I cant seem to solve that one. Also the other is that I'm using app (append). How can I delete … | |
hello, another stupid question but what is wrong with this? [code] infile.open("new.txt",ios::app); if (infile.fail()) { cerr << "Error"; exit(1); } [/code] ever since I've added the ios::app it keeps printing error and then haulting but from my resoruces if you want to append a txt file thats whats the syntax … | |
I am trying to write a program that reads in a file of numbers, writes to a file and displays the numbers in correct order. I don't fully understand how to read the file and pass that information into my class declarations in order to output before and after the … | |
HI: Maybe some of you read my thread about how to sort a file that contained 17 students data: ID LASTNAME FIRSTNAME 10 SCORES My program had to read this file, sort the names alphabetically, then calculate average score and letter grades. Finally send all data to a new file … | |
Hello: I need help with a project. I have to read an input file that contains data for 17 students. This is how they are: first ID, then first name, then last name, then 10 test scores. For this data, I have to read it and process it to send … | |
Hi, I have a somewhat odd and complicated question. Some background: I am trying to open up a file which contains formatted numerical data, find certain elements, and then overwrite these elements with corrected data. So, my plan was to just iterate until I found the data, use .tellg() to … | |
Hello. I thought I was done with this program but It doesn't work like its supposed to. I wrote the program to display the file every time I press one. But it only works the first time. After that it jus keeps sayin cannot open file. Why does it say … |
The End.