90 Topics

Member Avatar for
Member Avatar for mochiboo5

hello everyone, I am having a major problem with this assignment that asks to create a function whose input is a reference to an input file, which asks user to enter a file name to open for input, then checks to see where the file opened successfully. the function returns …

Member Avatar for Karkalash
0
258
Member Avatar for кодирование

First of all, just registered and this forum looks great! PROBLEM: My program which I wrote in Code::Blocks, has compiled fine and has worked fine, but when I run the outputted file called (BINDED.exe) it shows a very quick console window then closes, I think this is due to the …

Member Avatar for georgeduroa
0
166
Member Avatar for maharjun

I have noticed the foolowing details regarding fstream. the following combination of openstate flags do not truncate the files. ios_base::out | ios_base::in | <any flag other than ios_base::trunc> ios_base::out | ios_base::app | <any flag other than ios_base::trunc> the following combinations are resulting in a failbit ios_base::app ios_base::ate ios_base::app | aos_base::ate …

Member Avatar for TTTHXC
0
327
Member Avatar for Zemorg

Hey guys, i'm Working On A Project That Gets All Employees And Their Data From the User Then Saves Them in A Txt File ( Fstream ) Anyway, i figured out how to Do That But What im at stuck at now is how to search through the txt file …

Member Avatar for Clinton Portis
0
1K
Member Avatar for pattmorter

a friend asked me to help him with his lab. the lab involves opening a file and adding the numbers in the file together displaying how many even and how many odd numbers there are. I have the file "textinput.txt" in the directory with the .cpp file but when i …

Member Avatar for pattmorter
0
287
Member Avatar for кодирование

How would I go about attaching a stub to my payload, which shall control the execution of the payload. I have looked into file mapping [url]http://msdn.microsoft.com/en-us/library/windows/desktop/aa366556%28v=vs.85%29.aspx[/url], but I am not 100% certain this is the right way to do that? Thank you.

0
84
Member Avatar for ThomsonGB

//////////////////////////////////////////////////////////////////////////////////////// // In this little project I am trying to learn to get and manipulate data from // a file input using fstream strings I also wanted to use the formating available // with the printf and related string handling methods. I have a question in regards // to the …

Member Avatar for ThomsonGB
0
252
Member Avatar for muse_squall08

[CODE]#include <iostream> //standard input and output #include <fstream> //file input and output #include <string> //for strings #include <exception> //catches exceptions #include <sstream> //stringstream comes from here #include <algorithm> #include <stack> #include <queue> using namespace std; bool writeFile(const string &data); //writes strings to file bool readFile(); //read file bool palin(const string …

Member Avatar for WaltP
0
2K
Member Avatar for slygoth

Hey guys. Im trying to open a file the user entered. [CODE] cout<<"Please enter the file name"; cin>>name; cout<<"Do you want to open the file? [yes] or [no]"<<endl; cin>>pick; if(pick=="yes") system("C:\\wmplayer.exe [COLOR="Green"]fname[/COLOR]"); else cout<<"Good bye"; [/CODE] How do i get the value thats in fname to be printed their so …

Member Avatar for peter_budo
0
191
Member Avatar for slygoth

Im trying to open a file. The user enters the name of the file they want to open example [CODE] string fname; string pick; cin>>fname; cout<<"Do you want to open the file?"; cin>>pick; if(pick=="yes") system("wmplayer.exe [COLOR="Green"]fname[/COLOR]"); else cout<<"Thanks for your time; [/CODE] Can someone show me how the replace the …

Member Avatar for WaltP
0
250
Member Avatar for slygoth

In this code i would like to store the values that are being outputted. [CODE] fstream filestr; char check[4]; filestr.open("D:\\bio.pdf", fstream::in | fstream::binary); if(filestr.is_open()) { int i; char check[4]={0}; for(i=0;i<4;i++) { filestr.read(&magic[i],1); [COLOR="Red"]cout<<hex<<static_cast<int>(check[i])<<endl;[/COLOR] //<-- This LINE } } [/CODE] The numbers that are printed here i would like to save …

Member Avatar for slygoth
0
104
Member Avatar for George_91

I've to make several experiments of some algorithms. I want to send those results to a .txt file [CODE] //.... for (count= 1; count<= 20; count++){ //.... std::cout<<exp<<"Time: "<<duration << " seconds" <<'\n'; ofstream f2; f2.open("results.txt", ofstream::out); for(int i=0; i<=20; i++){ f2<<duration<<endl; } f2.close(); } [/CODE] With this code, I …

Member Avatar for MachDelta
0
179
Member Avatar for slygoth

Hey guys. I just learn about magic numbers today. I am trying to make a program that uses fstream along with magic numbers to tell what a file is. Example the magic numbers for jpg are ff d8 ff e0. How do i check a file to see if its …

Member Avatar for Ancient Dragon
0
1K
Member Avatar for imgregduh

i have 3 files one main.cpp, functions.cpp, and a header.h im using [CODE]#include<fstream>[/CODE] in the main.cpp and in the functions.cpp but im not sure where to define the ofstream datatype in, so that the main.cpp and the function.cpp share the same ofstream variable. where do i put this "ofstream outf;" …

Member Avatar for raptr_dflo
0
218
Member Avatar for slygoth

I am trying to open a text file in C++. I dont want the file to be open in the console i want to open the file using one of the text editors like gedit. Can someone show me how to open it using gedit and not in the console. …

Member Avatar for Stefano Mtangoo
0
271
Member Avatar for slygoth

Hey guys i am having a little trouble with this code [CODE]# include <fstream> # include <iostream> # include <string> using namespace std; int main() { fstream filestr; filestr.open("text.txt", fstream::in | fstream::out | fstream::app); filestr.close(); return 0; }[/CODE] But i keep getting a error when i run it 1> All …

Member Avatar for slygoth
0
97
Member Avatar for Zssffssz

Ok here it is: I want to read a file backwards, the catch is that I want to do this in binary mode to make a, really lame, data encryption program. Is there any easy way (<10 lines) To do this?

Member Avatar for vijayan121
0
650
Member Avatar for ben1996123

What I want to do is read a whole paragraph of text from a custom file. How would I do this without doing something silly like this? [CODE]while(someFile >> word1 >> word2 >> word3){ //etc. }[/CODE] I need to be able to read 3 numbers for todays date, then read …

Member Avatar for Zssffssz
0
924
Member Avatar for KanazawaFTW

I have an assignment to create a file with number 1-20, and another one with numbers 100-5 decreasing by 5. I've got those two down, but then I need to multiply both those files together one by one and have the answer output to another file. ie: 1*100= 100, 2*95= …

Member Avatar for Clinton Portis
0
188
Member Avatar for alexander1s

i have to count three districts 1, 2, 3 whom said no and whom said yes, which i had saved it in notepad the three districts. i have to use the while loop. i was trying ifstream iFile; inFile.open("vote.dat") while(district1 == yes) { cout <<"the district 1 said yes: "; …

Member Avatar for ben1996123
0
109
Member Avatar for googlygoo

Hi! I'm a newbie in this forum. I'm a novice C++ programmer and we are tasked to create a program with the following requirements: [QUOTE]Given the sequence of numbers [I][B]n a1 a2 a3 . . . an[/B][/I] a simple histogram should be printed to the computer screen. The number [B][I]n[/I][/B] …

Member Avatar for vijayan121
0
419
Member Avatar for seamus400

I've found some similar posts on opening different files with the same file stream but they are difficult to understand. I'm trying to figure out for a larger project why I can't use the same file stream as in this example and what an alternative solution may be. And yes …

Member Avatar for seamus400
0
4K
Member Avatar for yoni0505

I had a problem with some program I wrote that edit specific values within a specific file. When I saved the values, using fstream's write() function, everything between these values became null. I've looked again in the I/O tutorial - [URL="http://www.cplusplus.com/doc/tutorial/files/"]http://www.cplusplus.com/doc/tutorial/files/[/URL] and saw that they use memory block at the …

Member Avatar for yoni0505
0
340
Member Avatar for yoni0505

Hi I have a problem with a code I made, some save editor for some game. The code suppose to write 2 bytes to a specific offset in some file. The file's short integers are saved as little endian. everything works fine, but when one of the integers equal 10, …

Member Avatar for yoni0505
0
201
Member Avatar for DerrickC

I have written the following program. It collects inventory information and stores it in a file. I need to write a separate program that will access that file and give me the totals of the information stored in it ie. (quantity,wholesalecost,retailcost). What I'm specifically having trouble with is how to …

Member Avatar for DerrickC
0
182
Member Avatar for penguino138

Hi. I wasbwondering if there was a way to have the user input something to a string and then write that as the filename. Please use my example of the string deckname.

Member Avatar for penguino138
0
265
Member Avatar for cestra

[COLOR="Red"][B]//This is the main file[/B][/COLOR] [CODE]#include<iostream> #include<fstream> #include<string> #include "Books.h" #include"account.h" using namespace std; int main() { cout << "\tWelcome\t" <<endl; cout << "1-Login" <<endl; cout << "2-Register" <<endl; cout << "3-exit" <<endl; cout << "Please enter a choice: "; cin >> choice; switch (choice){ case 1: system ("cls"); cout …

Member Avatar for cestra
0
202
Member Avatar for flowerzink

Hello guys! I'm having a rather pesky problem working with fstream. I could write, for example: [CODE]fstream file("text.txt");[/CODE] then file should be open in read/write mode. But then if I do the following: [CODE]file << "Some text"; file >> string_var;[/CODE] or in the opposite order, it will only perform the …

Member Avatar for Ancient Dragon
0
163
Member Avatar for zyberb

Hello, im trying to make a program that reads from a file and sums up only the numbers.the numbers ar aranged like this in the file: 100er34 67 yyy 7 5 63 6 1 My problem is that the program sums up wrong,it sums some numbers twice when it see …

Member Avatar for Insensus
0
282
Member Avatar for yozzie

Alright - this is my conundrum. As a noob to C++ I am only in chapter 9 of my book, having just covered object oriented programs and the exciting world of vectors and arrays. I have an assignment that asks me to run a loop to get and calculate a …

Member Avatar for yozzie
0
2K

The End.