2,025 Topics
![]() | |
Hey guys, I've been having some trouble setting ios:: flags. In general I don't use [inlinecode]using[/inlinecode], but without it what I do doesn't work. [code]#include <iostream> #include <iomanip> using namespace std; int main() { double moneys = 5.2; cout << "$" << moneys << "\n" << "$"; cout << setiosflags(ios::fixed) … | |
Note: second post contains more info about where I'm having a problem... what I'm expecting to do and what the program is actually doing. Hey all, I'm finishing up an assignment for my C++ class and I can't figure out why the program stops in the middle of it. The … | |
Can anyone tell me why this is happening? All the code and input files are below. Stack.h [code] #include <iostream> #include <vector> using namespace std; const char FILE_NAME[] = "palindrome.txt"; typedef char StackElement; class Stack { private: vector<StackElement> myVec; public: bool Empty() { return (myVec.size() == 0); } void Push(StackElement … | |
can anyone help me to convert this project to VISUAL C++, i am unable to convert this to the new visual c++ as i am doing a assignment in converting this. I have tried everything i know as i am a diploma student but unable to get any answers please … | |
hi, this should be a fairly simple question to answer. I have a function in my program that takes the content of a text file and populates an array with all the information. First it has to see how many lines the file has (as it can change) so it … | |
Hi I want to increment file number with date e.g 19-FEB-09-1.dat, 19-FEB-09-2.dat .... So in the write function after it runs for certain number of times say 12 the file number then increments to next one. However, if the file number already exists it then move to next number to … | |
I just started learning C++ for a computer class at my highschool. I started learning about "if" and "else" statements so i wrote a program around that. It calculates the average GPA for the semester or total (if you want it to). It also factors in AP and Honors points … | |
hey, I'm trying to code a program that will accept a text file input for the dimension and elements of a matrix and store that to an array. Then the program will calculate the determinate of the matrix and output it to both the console and a file. I'm having … | |
[CODE= cpp] #include <iostream> #include <ctime> #include <cstdlib> #include <iomanip> #include <fstream> using namespace std; const int MAX = 51; const int setArray = 5; float initialArray[MAX][setArray]; void createRationalNo (int, int); float RationalInfo (float[][setArray], int); void printArray (float[][setArray], int); int main() { cout << "No\tP\tQ\tQuo\tRem\tValue\n\n"; srand(time(NULL)); int setPQ = 2; … | |
I've been trying to convert my code from using iostream to fstream but seems the output file is always empty.. this is my original code [CODE]#include <iostream> #include <cstdlib> #include <ctime> #include <iomanip> using namespace std; struct RationalNo { int RatNo [20]; }; struct RationalInfo { RationalNo rational; int quotient; … | |
I'm pretty new to writting c++ and i made this file to create a random x and y coordinate and place a bitmap image upon it, i made the program save the coordinates to .dat files *or txt i dont really care at this point* now i want a way … | |
I am in the last part of the program and everything is working but one final thing. I need to get all the Subtotals, taxes, and total cost to add up....I tried using sums, counts, and change the variable names and still having trouble....this program has been a real pain … | |
I am to open a text file, copy it, increment its ASCI characters by ten and then write it into a created text file. This is the code that I have so far.(visual c++ 6.0). The problem is that I cannot increment the characters. It gives me and overwrites my … | |
[COLOR="Red"][B]Circle.h[/B][/COLOR] [code=c++] #ifndef CIRCLE_H #define CIRCLE_H #include <iostream> #include <fstream> using namespace std; class Circle { friend ostream& operator <<(ostream& output, const Circle& aCircle); friend istream& operator >>(istream& input, Circle& aCircle); public: Circle(); Circle(double radius, int id); Circle(const Circle& aCircle); void SetCircleRadius(double radius) { _circleRadius = radius; } void SetCircleId(int … | |
Guys I am completely lost....what I want to do is make a loop to where the code im about to show. The issue is I need when I type a negative number in hotdogs, tacos, etc to make me type an error message and stop the code...here is my code … | |
What I need to do i something like this: [B]ClientData.h[/B] [code=c++] #ifndef CLIENTDATA_H #define CLIENTDATA_H #include <string> using std::string; class ClientData { public: ClientData(int = 0, string = "", string = "", double = 0.0); void SetAccountNumber(int); int GetAccountNumber() const; void SetLastName(string); string GetLastName() const; void SetFirstName (string); string GetFirstName() … | |
I need help in writing a C++ class definition called SIMPLEST_GRADES which will evaluate the students performance. It will take the three exams of four students and takes its average of those three exams. Can you tell me what I can do to fix this program or do I have … | |
(Note: sizeof(character) == 68 bytes) I am having issues with fstream::seekg()/seekp(). It seems like when one is invoked to modify the get or put pointer, the other pointer follows it instead of staying in place. Example: [CODE=cplusplus] charfile.seekp(0,ios::beg); cout << endl << "Put pointer is at " << charfile.tellp() << … | |
I need some guidance on an assignment I'm working on for school. The objectives of this assignment are to read data from a binary file, use some basic class functionality, store objects in an array and produce a neatly formatting report. [code] #include <fstream> #include <iostream> #include <cstring> using std::ifstream; … | |
I need some guidance on an assignment I'm working on for school. The objectives of this assignment are to read data from a binary file, use some basic class functionality, store objects in an array and produce a neatly formatting report. [code] #include <fstream> #include <iostream> #include <cstring> using std::ifstream; … | |
Write a program that accepts the number of people in each of the three age categories, performs the necessary computations, and displays a bill for the group's admission similar to the display below. Be sure to test for a variety of values. Here is a sample display after three values … | |
I'm making a program that is supposed to store the circles in a file, each circle should have an id and a radius. after i Add some circles to the file i need to open it again and search for a specific Id to display it. Here's what I've done … | |
I'm getting 3 unresolved external symbol errors. I think it's probably syntax but I can't seem to find it. This is a class I was supposed to write based on the professors specifications. The header and implementation file are mine, while the driver file cannot be edited for this assignment. … | |
ok I got this far in the code but I can't seem to get a person to enter an age and the program to return the info of those with the same age. I think this is what I need to use...or at least something like this on my code. … | |
I took out a lot of code, hence all of the variables you can't see, but for some reason, this part is the only one thats screwing up. When you enter zero, its supposed to "cout" a phrase that you don't have money, but when I run it, it tells … | |
Hello guys, how are all you doinbg ? Well I just created this program to cound 24 hours. The program runs fine but my only problem is when I ran the programs i get the following [inlinecode]0:0:0 4469690:0:1 4469690:0:2 [/inlinecode] Where is the number 446969 coming from ? I am … | |
I am writting a program that makes use of a vector of objects. Every time I add an object the windows system encounters a problem and needs to be closed. [code=c++] #include<iostream> #include<fstream> #include<string> #include<vector> using namespace std; class Catalogue { public: string vendor; string item; float price; int code; … | |
Hello, I have been stuck on this for awhile, and can not seem to get it to work exactly correct. I am trying to read in a file ("in_text.txt") and print out it's contents to the screen for now (eventually i will manipulate the data with a block_cipher class). Here … | |
Greeting guys Rookie here again. By the way, thanks for all the help. Anyway to business. I am trying to compile a program to understand how to handle exceptions using inheritance. I have created first error.h where all the classes and child classes are defined. Then when I create my … | |
I have this simple program. I created a file called input.txt containing a list of names and I want to read from it. I have two versions of the program. The first one only gives me the first letter in the file and nothing else. The second one does not … | |
Hello everyone, My name is David and I am new to these forums as far as posting goes, but I have used alot of the advice given here in my programs. I have come across a problem though in my program that I cant seem to figure out why it … | |
I have the following program and it works but when i try to append to the file, it will not do it. Can anyone help, Thank you GCard [code=cplusplus] #include <fstream> #include <iostream> using namespace std; int main() { char buffer[256]; // open it for output then write to it … | |
Hello everyone, I am trying to make a program which takes two integer parameters (HeightinInches,HeightinFeet) i.e. (7,30) and then displays the output by converting it into feet and inches. I am using three operators i.e. +,++, a constant integer number=27. After compilation I got following major errors in which I … | |
My program works properly under windows, however, it seg faults when I try to compile/run it under linux. [code=c++] #include <fstream> #include <iostream> using namespace std; int main() { char command; char infilename[80]; char outfilename[80]; char fileline[80]; char nextline[80]; char temp[80]; char temp2[80]; char * location; char sentence[250]; int loc … | |
hi I am trying to write into a file which already has something in it. like for example i have x y z in the file and if i want to put k after x,y and z like x y z k. my code goes this way [code=c++] int main … | |
Hi, i have been trying to do the following problem for homework, ialthough i have been able to input some code using the psuedocode given to me im am completely stuck now, and i was wondering if anyone could show me what i am missing? Question Use a single-subscripted array … | |
Good evening ladies and gents, Had a question concerning this piece of code that I'm trying out from a book, it supposed to open a file, write text to it, close it, reopen it, append text to it and then write the text from the file to the console screen, … | |
hi, Would anyone show how to delete a specific line from a txt file? Is there a member function from the ios class? thank you. | |
Hi all, Plz helpme out with this error. I am trying to Port my C++ compiler from Sun C++ compiler to GNU gcc 3.4.2 and i am getting below errors..Guys any idea how to solve this. [code] In file included from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/bits/stl_algobase.h:72, from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/bits/char_traits.h:46, from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/ios:46, from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/ostream:45, from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/iostream:45, … | |
In the following code, the object is not being written into file in line 30 [ICODE]stfile.write((char*)this,sizeof(item));[/ICODE] When line 26 :[ICODE]stfile.read((char*)&ob,sizeof(item));[/ICODE] is hidden the object is written into the file. Please help!!! [CODE=C++] fstream stfile; class item { int code; char name[25]; int price; int qty; public: int getcode() { return … | |
Here is my scenario i have a file 2000 bytes long. I want to read bytes 500 - 1500 so that i have the middle 1000 bytes stored. I then want to disect the 1000 bytes into 20 bte chunks and preform calculations on ever 20 byte sectiong until the … | |
Hi my problem is as follows. I want to stream a certain amount of bytes from usbimage2.txt until my buffer is full then write them to new.txt. My first problem is my buffer. If i give the buffer a value of say '4' it compiles with no errors. However i … | |
Hi i want to use create file to get a handle on my USB device so that i can stream from it. However i am having problems. To me i appear to have the syntax correct but i get errors returned in the form of "Undefinded symbol HANDLE" "statement is … | |
in the following code, getch() is executed before the file is displayed.! whats wrong? how can i correct this? [CODE='c++'] void ReadFile() { char fname[13],ch; cout<<"Enter filename : "; cin>>fname; strcat(fname,".mth"); temp.open(fname,ios::in|ios::nocreate); if(!temp) { cout<<"File does not exist!!!"; getch(); return; } temp.get(ch); while(!temp.eof()) { cout.put(ch); temp.get(ch); } temp.close(); getch(); } … | |
i posted this problem in C++ forum and people told me its impossible. I'm using a very old version of C++ and most of its features are very similar to C. So i thought maybe you people will understand what the problem is.... In the following code, getch() is executed … | |
Please help me in self documenting the program below. All you have to do is, take a quick glance at the following code to see if you can understand what each part is doing. If you have any difficulty in understanding(at a quick glance that is!), please tell me, so … | |
Hi again, i'm making a macro building pogram. I have got mouse movement down, but now i have no idea how to do mouse clicks or keyboard input. Please help! I'm also using dev-c++ 4.9.9.2. Here's my complete code for the program. [code=c++] POINT MousePoint; int X = 0; int … ![]() | |
Please help me in self documenting the program below. All u have to do is, take a quick glance at the following code to see if u can understand wat each part is doing. If u have any difficulty in understanding(at a quick glance that is!), pls tell me so … | |
Sorry, this is going to be a very long post :$ first of all, here is my codes: [b]Header File[/b] [code=c++] struct hardware { int record; char name[100]; int quantity; float cost; }; [/code] [b]Binary Input File cpp[/b] [code=c++] #include<iostream> #include<iomanip> #include<fstream> #include <cstring> #include "hardware.h" using namespace std; void … | |
I've been working on a project for a few days now, and I am running out of time by trying to research everything I am doing. My task for this particular program is to create an inventory program that reads from a file and then allows the user to manipulate … |
The End.