C# :: How To Create Event To Notify And Save / Write Information To File

Feb 24, 2014

I am writing a program that models the ups & downs of a particular stock. Everything is pretty much done, except that I need to create another event to notify that saves the following information to a file when the stock's threshold is reached: date & time, stock name, initial value & current value. I have something like this so far:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

[Code]...

I feel like i need something along the lines of

s.stockEvent += new Delegate( ???? ) in my myFile class so it know when the threshold is reached, to write the information of the current stock to the file.

View 14 Replies


ADVERTISEMENT

C/C++ :: How To Create A Txt File - Read / Write And Open For More Information

Jan 25, 2015

How do i create a text file read and write in it but every time i reopen the program i must not override the data in the text file .

View 6 Replies View Related

C :: Create A File And Save Text In It In PDF Format

Feb 13, 2014

My objective is to create a file and save some text in it. But the twist is that file should be created in pdf format.

I have written following code:

Code:
#include<stdio.h>

Code:
int main() { FILE *fp;
char ch;
fp=fopen("file.pdf","w");
fprintf(fp, "%PDF-1.3"); //to initiate data storage in pdf file
printf(" Enter data to be stored in to the file:");
while((ch=getchar())!=EOF)
putc(ch,fp);
fclose(fp);
return 0;}

Now my file is created in pdf format, but when I open it by double click on it, it is not open and gives the message like: "Error in opening document. This file is damaged and could not be repaired."

View 1 Replies View Related

C++ :: Create Save File For A Game That Is Not A Separate File?

Oct 10, 2014

How do you create a save file for a game, that is not a separate file? Specifically I am using code::blocks and sfml 2.1 to make a game and it saves to a text file at the moment. My problem is that it is very easy to modify the text file, and it is annoying to have to copy and paste several files if you want to use a copy of the game. I have a feeling that it may be to do with resource files, but I'm not exactly sure how to get these to work or whether you can modify them dynamically.

View 6 Replies View Related

C++ :: Create A Program That Is Able To Save Database Of Items To File On Hard Drive

Mar 18, 2013

Write a program that is able to save a list of items such as books, CDs, or DVDs and the items that are saved must have attributes associated with them. For example a book has a title, author, publisher, and ISBN.I would like to create a program that is able to save the database of items to a file on the hard drive and also retrieve it from the hard drive.I have this for a start of how to set up a storing program.

#include <iostream>
#include <iomanip>
using namespace std;
int main () {
const int arraySize = 10;
int a[arraySize] = { 2, 6, 4, 10, 12, 89, 68, 45, 37 };
int i, hold;

[code]....

View 2 Replies View Related

Visual C++ :: DLL And Write To Event Viewer

Dec 11, 2013

i want to write to event viewer

Code:
void EventLogCls::WriteError( char* msg) {
HANDLE hes = RegisterEventSource(0, appName);
if(hes) {
WORD dwEventType = EVENTLOG_ERROR_TYPE;
ReportEvent(hes, dwEventType, 0, 0, 0, 1, 0,(const char**)&msg , 0);
DeregisterEventSource(hes);
}
}

The error that i get is on the line of "ReportEvent"

error C2664: 'ReportEventW' : cannot convert parameter 8 from 'const char **' to 'LPCWSTR *'

what should be changed?

View 3 Replies View Related

C :: Create File To Write Text And Read Back The File Content

Mar 15, 2013

The Objective Of This Program Is To Create A File To Write Text And Read Back The File Content. To Do That I Have Made Two Function writeFile() To Write And readFile() To Read.The readFile() function works just fine but writeFile() doesn't.

How writeFile() function Works? when writeFile() function Execute It Takes Characters User Type And When Hit Enter(ASC|| 10) It Ask "More?(Y/N)" That Means What User Want? Want To Go Next Line Or End Input?

If "Y" Than Inputs Are Taken From Next Line Else Input Ends.

But The Problem Is When Program Encounters ch==10 It Shows "More?(Y/N)" And Takes Input In cmd variable.If cmd=='Y' I Mean More From Next Line Than It Should Execute Scanf Again To Take ch I Mean User Input.But Its Not!!! Its Always Showing "More?(Y/N)" Again And Again Like A Loop.

Code:
#include <stdio.h>
void writeFile(void);
void readFile(void);
int main(){

[Code].....

View 5 Replies View Related

C/C++ :: Create And Write To Text File And Then Read From It?

Mar 26, 2014

I have looked through te tutorials here, and even google it, as well as tried to follow the power points from my class..but I still can't seem to figure out how to make this code work correctly.. Basically I have to create a file called grade and write to it a student name and their grade score, and then read from the file all students names and there grade and display this on the screen as well as calculate the grade average for all of the students and display it.

Well I am able to write to the text file, but I can't seem to get the rest to work. I can't figure out how to read from the text file..Here is my code below.

write a sample code that does something similar write to text file string and numbers and then reads from it.

#include <iostream>
#include <fstream>
using namespace std;

[Code].....

View 6 Replies View Related

Visual C++ :: Unable To Save File Using Cfiledialog Save As In MFC

Nov 5, 2013

I am trying to develop a GUI using MFC, but I am having trouble using CFiledialog to save a file. The problem is, the file is not getting saved to the folder when I use the CFiledialog. Below is the code I am using.

Code:

CString szFilter = "XNRep Files (*.xnrep)|*.xnrep||";
CString s = "xnrep";
CString t = "";
CFileDialog fileDlg(FALSE, s, t, NULL, szFilter);
if(fileDlg.DoModal() == IDOK)
{
std::ofstream file;

[Code]....

After the file dialog opens up, I enter the name of the file and select OK button. But the file does not show up in the directory I am saving to.

View 4 Replies View Related

C++ :: Using Binary Write To Save A Struct

Aug 13, 2013

I'm still reading Prata's book and there is a section where they explain how to write files using the binary mode.

They define a struct

Code: const int LIM = 20;
struct planet
{
char name[LIM];
double population;
double g;
};
planet pl;

And they say you can use the binary mode to write the whole struct at once (in text mode you need to specify every member).

Code: ofstream fout("planets.dat",
ios_base:: out | ios_base::app | ios_base::binary);
fout.write( (char *) &pl, sizeof pl); I don't understand why they use Code: fout.write( (char *) &pl, sizeof pl) instead of just Code: fout.write( pl, sizeof pl)

View 4 Replies View Related

C :: Create A Structure To Store Information About Products For Sale

Apr 29, 2013

I am using Dev C++ compiler on Windows 7 and was programming a piece of code that is supposed to do the following -

Create a structure to store information about products for sale in a store. It should store information about the product name, the price, and the product number and then create an array of products called Inventory. Add five products to your inventory.

But for some reason, which is unknown to me, I always seem to get a compiler error. And this is what i have so far -

Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct product{
char name[30];
int product_number;
double price;

[Code] ....

View 4 Replies View Related

C++ :: Create Structures To Store Information Of The People To Be Matched

Nov 9, 2014

I need to be able to make matches from the data i input, and also classifying between male and female. matches for person with specific traits (not one in the program) i really tried for the first part and now the rest is mentally disturbing me. and also to generate a report of partners found.

#include<string.h>
#include <iostream>
using namespace std;
char username[20];
char storedusername[20];
char password[20];
char storedpassword[20];
int loginresult;
char name[20];

[Code] .....

View 1 Replies View Related

C++ :: Create Dynamically Allocated Array And Input Some Information

Feb 25, 2013

I am having some trouble on understanding how to create a dynamically allocated array and then inputting some information in to it from a text file.

Example text file:
John Doe saving 135246978 300 0

View 1 Replies View Related

C :: Create Program That Takes In Information And Formats It Into 3 Columns - Float Variable Not Working

Dec 12, 2013

Here your supposed to create a program that takes in information and formats it into three columns.

I can't seem to use the float variable unitprice with decimal places here for, if I try to use %.1f and type in an input, the program seems to skip over the second scanf function, not allowing me to put input into the third scanf function as the program runs before I can.

I can use %f on its own and it works but this creates too many zeroes(and you're supposed to set the currency limit to $99999.99).

Code:
#include <stdio.h>
int main(void) {
int itemno, month, year, day;
float unitprice;

[Code]....

So the output should look like three columns. It's just the float that is the issue here....

View 5 Replies View Related

Visual C++ :: Application Which Print Existing File On Reception Of Network Event

Sep 10, 2014

I basically want to develop an application which print an existing file on reception of a network event (application will be running on a seven 64 bits PC).

I wonder which application type would be the most suitable (and the simplest) for that (console win32, win32 app, MFC app ...). As this application does not need user intervention (print on network event), I'm not sure that I need a MFC application or a win32 app.

View 9 Replies View Related

C :: Create 9 Child Processes And Eventually Write From Each Process To Another?

Nov 18, 2013

I want to create 9 child processes and eventually write from each process to another. How can I specifically create 9 child processes and leave them running? Right now, I am using a loop from i=0 to i=8 and running fork() within that loop, but each child process also runs the loop, which spawns dozens (maybe hundreds?) of processes. I specifically only want to create nine of them. How can I do this?

Code:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>

[Code].....

View 7 Replies View Related

C Sharp :: Data Save But 2nd Record Doesn't Save

Jan 28, 2015

1st when i fill the things on form then saved in database after saving record when i want add another record it shows an error. after saving it saves new record refresh doesn't work

View 1 Replies View Related

C++ :: How To Save File Directory To Text File Using Ofstream

Jul 22, 2013

I'm having a little problem with std:fstream - in my program, the user selects the location of a file which I want to remember. So, I have something like this:

Code: std::string fileLocation;
//Code here creates an 'open file' dialog box which lets the user choose which file to open.
//The string 'fileLocation' now contains the path to the chosen file.
std::ofstream prefs("prefs.txt");
if (prefs.is_open())
{
prefs << fileLocation;
prefs.close();
}

This works fine if the file chosen is in the same directory as the program, however, if they try to choose a directory outside of where the program is kept, it saves the text file into that directory instead of the same one as the program. So, it looks like outputting a directory into an ofstream actually changes the location to which the file is saved.

Is there a way to save the file directory to a text file using ofstream and still have the text file save in the same directory as the program?

View 5 Replies View Related

C++ :: How To Save Struct To File And Then Read It Back From The File

Aug 5, 2013

How to save the struct to file and then read it back from the file ?

Code:
#include <conio.h>
#include <stdio.h>
struct student {
int person;
int egn;
float AvergeGrade;

[Code] ....

Have average grade: %f", person[i].FirstName, person[i].LastName, person[i].egn, person[i].AvergeGrade);
}
//Save to file
getch ();
}

View 2 Replies View Related

C :: Reading From File Certain Information

Jul 31, 2013

//---------------------------------------------------------------------------------------
//FUNCTION: vDelEditStudents()
//---------------------------------------------------------------------------------------

void vDelEditStudents() {
FILE *file = fopen("C:UserForCtxtgiro.txt", "rb");
Student StdStruct;
fseek(file, -sizeof(StdStruct) , SEEK_END);
fread(&StdStruct, sizeof(StdStruct), 1, file);

[Code] ....

The problem is that ... Even though it is reading from a a file, it is not reading a one struct. In this piece of code I'm trying to read the last struct, which should be k... The struct itself is here

Code:

typedef struct {
char StudentName[30];
uint16 StdAge;
uint16 StdNumb;

}Student;

And here is my input and output:

INPUT:
4
1 g 1 2
1 h 3 4
1 j 5 6
1 k 7 8

View 4 Replies View Related

C++ :: Reading Information Out Of File?

Apr 12, 2014

I need to read some infos out of a .txt-file.

The problem is that i dont know how to do because 'getline' won't work i think.

the file looks like this:

*******************
Inventory of MyInventory
*******************
Some info
More info
-------------------
000 Toys 6.25
a short description
126/44 Cards 2.25
some text
*******************
Inventory of MyInventory2
*******************
Some info
More info
-------------------
000 Toys 6.25
a short description
126/44 Cards 2.25
some text

So what I need to know:

- the name of the Inventory (MyInventory, MyInventory2...)

- the numbers in each row (000,126/44...)

- the name what it is (Toys,Cards...)

- the price (6.25,2.25...)

- and the description(problem here is, that there are not the same amount of words for each description)

I tried it with 'getline' but this is not working because the lines are so different each time.

View 2 Replies View Related

C/C++ :: Receiving Information From A File?

Nov 13, 2014

I want to receive an information from a file. For instance, you created a file name "sample.txt" via fstream and stored a bunch of people's name, address, phone number in that "sample.txt".

Now, I want to see what's stored in this file. Suppose, I wanted some particular guys address, phone number by just typing is his/her name.

How to relate the name with address and phone number of particular people? I just started the file creating so I wanted to know about it.

#include<iostream>
#include<conio.h>
#include<fstream>
#include<string>
using namespace std;
int main() {
ofstream outputData;

[code].....

View 12 Replies View Related

C :: Add More Student Information To The Specific Txt File?

Mar 12, 2013

I'm trying to add more student information to the specific txt file. I did struct my student information and separated it with an array with max size of 200.

The inside of my current file looks like

Toshi
Aka
Nonal
Donald

The first one represent student[0] and next one is student[1] and so on till student[199]. Right now, only 4 space is occupied, which means the array has information till student[3] but not from student[4] (I guess it has null condition).

What I want to do is, I want to add a new student information to student[4] and till student[199] once at each time.

So, my prompt will look like
Would like to add a new student? Y/N
(if yes goes to below statement and exit if NO)
Hi. Please enter the information of new student. ___________
Student added. Please press any key to continue.

If the key is pressed, it goes back to my initial prompt and continues till I press N.

I sure I'm not using for loop to do this thing, because I'm adding student name one by one.

However, the array is already occupied by other student name till student[3] so, I want to add a new student information to student[4] (I don't want to overwrite the current information). And if student[4] is occupied, then [5] and so on.

View 7 Replies View Related

C :: Saving Information From A File To Struct

Jan 12, 2014

I want to take the informaition from this file and save it into a struct the file conteins name age year (in char) and a grade it is somthing like this

file
Nikos Tolis 19 A 8
Iwanna Nikolaou 20 B 9
Kwstas Doukas 20 Β 6
Georgios Pappas 19 A 7
Iwannis Lekatis 20 Β 7
Nikos Ntoumas 19 A 5
Maria Oikonomou 20 B 6
Kwstas Argyrou 19 A 10
Irw Ntouma 20 B 8
Leuteris Doukas 19 A 6

I want to read till i found the '32' the space in ascii here is my code so far

Code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct students
{
char *name;
int age;

[Code] ....

View 2 Replies View Related

C++ :: Parse A Text File That Contains Information

Jul 31, 2014

I am trying to parse a text file that contains information and i cant seem to get started. For example, the text file looks like this:

idx=929392, pl= 12, name= someperson
age=19
state=ma
status=n/a

idx=929393, pl= 12, name= someperson2
age=20
state=ma
status=n/a

idx=929394, pl= 12, name= someperson3
age=21
state=ma
status=n/a

I want to parse the name and age into another text file like this format:

someperson 19
someperson 20
someperson 21

possibly include other attributes next to the age like idx?

View 3 Replies View Related

C/C++ :: Extracting Information From Data File?

Apr 20, 2015

Create a simple data file like the example shown below containing the 4 dates below plus 10 or more additional dates. The file should include 1 date per line and each date should have the form MonthNumber-DayOfTheMonth-Last2DigitsOfTheYear with no extra spaces. All dates should be in this century. No error checking for invalid dates is necessary.

My Output displays like

February -19,1991

How do I get my program to ignore the dash between the dates?

#include <fstream>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(){
const int M = 13;

[code]....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved