2,025 Topics

Member Avatar for
Member Avatar for ChroNoS

I am still very new to C++ and I'm a bit :confused: too. I am trying to make a program which takes the ascii string from a text file and converts it into binary. I have been able to come up with this code so far: [ICODE] #include <iostream> #include …

Member Avatar for ChroNoS
1
110
Member Avatar for bomtk

Hi every one, i got a trouble with opening and reading multi files (200 files) in. These files include 4 columns and 1010 rows. event i have tried many times but it still can not work. if possible, could you please give me some suggestion on my code as the …

Member Avatar for bomtk
0
133
Member Avatar for mksakeesh

[code] #include<fstream.h> #include<string.h> using namespace std; class emp { public: char *per; void write() { ofstream out("ss.txt",ios::app | ios::binary); cout<<"Enter some character ....\n"; cin>>*per; //out.write(per,sizeof(per)); out.write(per,strlen(per)); } }; void main() { emp e; e.write(); } [/code] Why this is not working?

Member Avatar for Clockowl
0
162
Member Avatar for scarypajamas

I've have a class function below (using fstream) for my game that I had working on Visual C++ 2008. When I tried to port my app to xcode, I found it compiled, but complained that the directory doesn’t exist. Believe me, the directory exists. I've checked and rechecked! Basically this …

Member Avatar for iamthwee
0
1K
Member Avatar for guest7

Hi, I am trying to read the file (f1.txt) which contains : 3 0 -6 0 4 0 -8 0 ... I wish to read the first number from consecutive 2 lines and process them. Following is my code: std::vector<int> row; std::vector<std::vector<int> > two_node; int main() { string line1, line2; …

Member Avatar for Radical Edward
0
239
Member Avatar for Cosa

The aim of the program which i am writing is to convert strings of DNA. The DNA is in a text file and represented by the letters A, T, C, and G. Reading in the file and outputting the converted DNA is easy. However i want to save the converted …

Member Avatar for Lerner
0
142
Member Avatar for anshulagarwal

when i m using this code: its not complete code..assume everything is right... [code] for(int result=0;result<g;result++) { u1+=((a[result].real_z1*tw[result])/sumd); u2+=((a[result].imaginary_z1*tw[result])/sumd); u3+=((a[result].real_z2*tw[result])/sumd); u4+=((a[result].imaginary_z2*tw[result])/sumd); } cout<<"\n""Value of U1:"<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u1; cout<<"\n""Value of U2: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u2; cout<<"\n""Value of U3: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u3; cout<<"\n""Value of U4: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u4; ofstream abc; abc.open("result.txt", ios::out | ios::ate); abc<<endl<<endl; abc<<"Data at position [ "<<i<<" , …

Member Avatar for ArkM
0
427
Member Avatar for krebstar

Hi guys, its me again.. I was wondering if anyone could tell me how to test a character if it is within the ASCII range, like say in the following pseudocode: [CODE] ifstream in; in.open("file.xxx", ios::binary); if(!in) { cerr << "file.xxx could not be opened. \n"; } while (!in.eof()) { …

Member Avatar for krebstar
0
6K
Member Avatar for davidleeis14

C++ reading text files I have a program which I am writing which manages a savings club. I have set up a functions which creates members (there are two members types) and outputs there data to a text file a line at a time in the format string, int, int, …

Member Avatar for Agni
0
4K
Member Avatar for adamj2

Hi there, I want to read 1 byte of information, in the form of an array of unsigned chars [1], from a file. I then want to use this piece of data to act as a secret key for a message authentication code I will be performing. The key will …

Member Avatar for ArkM
0
177
Member Avatar for QuantNeeds

Hello, Finally I am down to the last issue with my program: text file writing and reading. My file has a function whose ofstream object does work and produces a text file for printing called "print". This function is the printTextFile(fstream &readFromFile ) function. But initially it is supposed to …

Member Avatar for Ancient Dragon
0
321
Member Avatar for QuantNeeds

I am having some issues. I was trying to use my setToolName function to copy the string into the array – this would check if the string was too long. But then it does not capture 2 words, say if the string is “lawn mower”. So I started to use …

Member Avatar for QuantNeeds
0
141
Member Avatar for QuantNeeds

Hello, I have seriously tried to work on this in different manners and now I am back to an infinite output. I have posted for the past 3 days and the responses have just been questions so I am not sure if this is something difficult but I really need …

Member Avatar for ArkM
0
83
Member Avatar for bpacheco1227

I have time to complete this, I have to add 2 void functions, 2 value returning functions, 1 structure and on array. I just need some ideas on where to start, what should I convert to functions, how should I instill stuctures and arrays to this particular program. I'm going …

Member Avatar for mitrmkar
0
200
Member Avatar for QuantNeeds

Hello, I need help to try and figure out why one of my functions does not write to the file. I have 4 functions (below) and all of them write to the file except the updateRecord function. I know this is the case because I keep checking the .dat file …

Member Avatar for Agni
0
160
Member Avatar for srisaravanavel

The below program works fine for a input file that has only one line. but goes to an infinite loop for a multiline file. Kindly suggest. [code][COLOR="Red"] #include<iostream.h> #include<conio.h> #include<fstream.h> void main() { char data[10000]; int i=0; ifstream ofile("c:\\temp\\welcome.txt"); cout<<"File opened\n"; // clrscr(); ofile.seekg(-1,ios::end); while(1) { if(ofile.tellg()==-1) break; i++; ofile.get(data[i]); …

Member Avatar for srisaravanavel
0
108
Member Avatar for QuantNeeds

I am not sure how to prevent the padded characters within a string array from printing. The user inputs the information in function enterRecords() and then prints in outputLine(ostream &output, const Tools &record ) function. I am having issues with outputline when I try to print to screen and then …

Member Avatar for Ancient Dragon
0
217
Member Avatar for masterjiraya

I have here the the cpp file named as clock [code=cplusplus] #include <iostream> #include <fstream> #include <string> using namespace std; #include <cstdlib> int main() { // ofstream constructor opens file ofstream outClientFile("clients.dat", ios::out); if(!outClientFile) { cerr << "File could not be opened" << endl; exit(1); } cout << "Enter the …

Member Avatar for masterjiraya
0
112
Member Avatar for cmatos15

Hey everybody, I seem to be stuck on this rolling dice problem I received on one of my lab exercises. Can somebody get me started on the right path. Here's a description of the problem along with the code given. The green indicates where I need to insert code. DESCRIPTION: …

Member Avatar for cmatos15
0
2K
Member Avatar for tapaditap

I'm having a problem with retrieving records from my file just started programming over a month a go please help this is for my class project. I need to do delete,update,query,and add to binary file and prompt the user to enter which record they need to retrieve and i started …

Member Avatar for ArkM
0
110
Member Avatar for Emerald214

I use VC++ 6.0 1) This small program simply reads infomation from file “in.txt” and write it in file “out.txt”. (copy contents from this file to another) 2) It doesn’t work. The compiler issues an execution-time error. And the ouput text file “out.txt” is empty. 3) I don’t know why …

Member Avatar for Emerald214
0
133
Member Avatar for Pikachumanson

Ok here is what I got so far. When you type add, it asks what object would you like to add When you type list, it lists those objects When you type exit, you leave the program What I would like to do is create a search function where I …

Member Avatar for Pikachumanson
0
264
Member Avatar for soroush68

I modified it by visual studio 2005 and it works with it correctly but i has errors by my old compiler(borland C++ 5.02). errors in the last code was caused by using clrscr(),gotoxy() & ... ,that functions was for just borland and was not standard. Does new code of this …

Member Avatar for soroush68
0
186
Member Avatar for Cosa

Hi, i am trying to write a program that would work much like the tail command in UNIX. The idea is to print the last 10 lines of a file. I started off by finding out how many lines were in the file, then attempted to seek to the appropriate …

Member Avatar for Cosa
0
4K
Member Avatar for originaldaemon

I have created a new windows form application and made a form using the editor in visual studio. This is the code that was generated in form1.h: [CODE]#pragma once namespace DatabaseForm { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; …

0
50
Member Avatar for JBtje

Hello, On a website I found the next source code "sniffer.cpp" [B]Sniffer.cpp[/B] [CODE=C++]/* OoOoOoOoOoOoOoOoOoO o HTTP-Sniffer o O www.1plus.se O oOoOoOoOoOoOoOoOoOo INFO: The trick is to use raw packets with SIO_RCVALL */ #include <iostream> #include <fstream> #include <string> #include <winsock2.h> #include <windows.h> #include <ws2tcpip.h> #include "packet_headers.h" using namespace std; #define …

0
90
Member Avatar for shaunkuro

I got some ploblem when i was doing smth here are the codes: // Wallhack.cpp : Defines the exported functions for the DLL application. // [code=cplusplus] #include "stdafx.h" /*creds to me,Roverturbo,Azorbix,Frit0 ,unreal*/ #include <windows.h> #include <detours.h> #include <d3d8.h> #include <d3dx8.h> #include "log.h" #include <fstream> #include <iostream> #pragma comment(lib, "d3dx8.lib") #pragma …

Member Avatar for mitrmkar
0
315
Member Avatar for originaldaemon

I am trying to create a simple database. Here is the code: [code=C++] #include <iostream> #include <fstream> #include "conio.h" #include <string> using namespace std; struct Station{ string url; string name; string genre; }temp; char userInput; string output; int fileSize; string searchParameter; int index; int results[1000]; int j;//temporary storage for a …

Member Avatar for Salem
0
99
Member Avatar for camproject

I have two dialogs as I told before.there is a combo box in the first dialog.i have a text box in the second dialog.when i click a button, i get the second dialog in which the text box is present.i get the data in the text box in the combo …

Member Avatar for mitrmkar
0
122
Member Avatar for seacat123

i have written the code . the while loop works good for right and down only. when i=9 and j=5 then it do not execute further . iam trying to fix the problem but not successful. #include <cstdlib> #include <iostream> #include <fstream> using namespace std; //----------------------------------------------------Print maze void fnPrintMaze(int m,int …

Member Avatar for seacat123
0
119
Member Avatar for SunshineLuvr

I am writing a payroll program with inheritance for a school assignment that has the following requirments: [B]Expand the Employee Payroll program to include hourly based and salary based employees. This phase uses an array of employee objects, inheritance for different classes of employees, and polymorphism for salary computation. The …

Member Avatar for mitrmkar
1
585
Member Avatar for autumngardens

Hi, I would like to know if it is possible to read a file and write to the same file at the same time. For example, if I have [CODE] #include <fstream> // and other headers string temp_string; char result; fstream studfile; studfile.open("student.dat", ios::in | ios::out); // Is this correct? …

Member Avatar for Ancient Dragon
0
114
Member Avatar for 13L4D3

Well i am a starter in programming and need ur help. M using older version of borland c++ for programming. M trying to make a program which adds users login and password information and also verifies the correct login and password by accessing the contents of those files. but there …

Member Avatar for 13L4D3
0
184
Member Avatar for mikelle

[code]// Lab 6 // This program tells what coins to give out for any amount of change // from 1 cent to 99 cents using three coin denomination: quarters, dimes, and // pennies. #include <iostream> #include <fstream> // function declarations istream &getData(istream &is, double &amount); void displayResults(ostream & os, double …

Member Avatar for Ancient Dragon
0
97
Member Avatar for wtf???

could someone show me how to read more then 1 line of text in a file and print it on the screen im kinda new at this tho i no how to do 1 line using namespace std; [CODE]int main() { system("COLOR 5"); system("TITLE tempature converter"); double dfirstNumber, danswer, firstNumber, …

Member Avatar for Narue
0
87
Member Avatar for wtf???

im new with c++ and dont know much but want to save the answer to the program i made when i do it names the file ÿÿÿÿ also the type of file is just called file how can i make it like .txt or somthing also just ignore the useless …

Member Avatar for wtf???
0
206
Member Avatar for wtf???

i spent a long time trying to fix this probably somthing stupid but please help me. i dont see any problem but its probably somthing stupid. it compiles ok and when i run it it works until i get to the equations it prints somthing like 1.62111e-307 here is my …

Member Avatar for wtf???
0
116
Member Avatar for mikelle

[code=cplusplus] //Lab 5 Ray Perales //This program will compute a user's hat size, jacket size, and waist measurement // based on a three function modular program. #include <iostream> #include <iomanip> #include <fstream> #include <cmath> // Prototype declarations double findHatSize (double height, double weight); double findJacketSize (double height, double weight, int …

Member Avatar for ivailosp
0
121
Member Avatar for camproject

I have a dialog based application.I use a text box in it.what i want is write the details from that text box into a text file. when i wrote the code ,the data written into the file was as follows..[COLOR="Green"]慨獮a﷽﷽楢畮ﴀ﷽ý晧晧ﴀ﷽ý[/COLOR] My code is, [COLOR="Green"]CString str; GetDlgItemText(IDC_EDIT1,str); fstream f; f.open("C:\\myfile.txt",ios::app); f.write((LPCTSTR)str,10); …

Member Avatar for camproject
0
202
Member Avatar for dannomite

Hello all. I'm trying to read a line of data in from a csv file and then assign the fields to it to an int w, string y, and double z **See code below** However, I have two problems: 1. The first is in reading in the all contents of …

Member Avatar for Ancient Dragon
0
102
Member Avatar for TeCNoYoTTa

hello all i want to know the proplem with this program and first ........ can i write a string object to a file normally like other objects ?? this is the code ......the program writes the file but it can't read it again [CODE=cpp] #include <iostream> #include <fstream> #include <string> …

Member Avatar for TeCNoYoTTa
0
84
Member Avatar for skatamatic

Ok. Originally I was trying to write a program that would calculate pi to infinite decimal places. The calculus baesd algorithm I made for this is flawless, except that C++ can only handle 16 digits! So I did some looking around, for libraries and what not, to find something that …

Member Avatar for VernonDozier
0
153
Member Avatar for all blacks

I wan to read from multiple files and write into 1 file....the fuse_cortex_header_r function will read a file and then break the file into several file which only consist of classes...for fuse_cortex_header_w file, i would like to read all the files which have been writen by previous function and write …

0
93
Member Avatar for mikelle

// Lab 4 read and calculation file/input // This program will read the data in the input file // used by grosspayMinustaxFileCode #include <iostream> #include <iomanip> #include <fstream> using namespace std; int main() // this is the error message it displays if not working right to EXIT { ifstream inFile; …

Member Avatar for mitrmkar
0
260
Member Avatar for maxiam

Hi I am trying to learn c++ by using it where I can at work. Usually I can muddle through by searching forums and although I might not end up with an elegant piece of code, my programs seem to work ;) What I am trying to do, is open …

Member Avatar for maxiam
0
139
Member Avatar for iansane

Hi, I am trying to learn how to read the binary of a file, such as a jpg. I got something going here but at run time in windows it says there is an error and the file must close. I'm not even sure if I'm going in the right …

Member Avatar for Ancient Dragon
0
933
Member Avatar for integer*09

Hi all, the while loop in my code dont seem to be working as i wanted it to. I wanted it to constantly check if new data is available in the sample.txt but curently after the button click it just finished with one try. is it i put everything into …

Member Avatar for Ancient Dragon
0
141
Member Avatar for all blacks

The program i am working on currently need to read a file and write into multiple files. Basically i am supposed to separate all the classes in tat file so i actually added an comment line to the file, i extract the classes according to the comments. Now i would …

Member Avatar for mitrmkar
0
148
Member Avatar for berge

Hi guys. I wrote a Win32 C++ program that uses C++ streams to open and read files. I log on a machine using a specific user (USER1) and password. It is supposed that this user has access to files spread across the network (file sharing). Therefore I'm using sentences like …

0
54
Member Avatar for ederX

Ok, I posted earlier and your suggestions worked fine, I had to rework the program a bit but it compiles now. The only problem is that it segfaults right away now. This is the gdb backtrace: [code] (gdb) backtrace full #0 0x95082630 in std::istream::sentry::sentry () No symbol table info available. …

Member Avatar for ederX
0
136

The End.