C/C++ :: Record Every Transaction That Made To A File Like A Receipt
Jun 19, 2014
I dont know anything about filestreams. I want to record the files that the customer bought, total, cash and change.
Here's my code.
// Create a program that will initiate a purchasing system for registered agents in an agency.
#include<iostream>
#include<windows.h>
#include<conio.h>
#include<fstream>
#include<string>
using namespace std;
void password();
I want to monitor a text file. So far what I have is the program reads and prints the names in the file to standard out. When the program reaches the end of the file, it closes.
I want the program to stay active and continue to print names as they are saved to the text file.
I was toying with FindFirstChangeNotification function, but it seems that returns a handle so I'm back to the drawing board.
I have a client/server program. My Client process spawns my server process using a `fork()` and `system()` call. The client and the server are meant to communicate to each other through named piped, that is a requirement of my homework. The client and the server are supposed to initially send a message to the other one, through a pipe, to confirm that a connection is made. My issue is that my client is trying to open one of the named pipes before the server has a chance to make it. This doesn't always happen though. Occasionally, it will run fine. Is there some way to synchronize this?
My overall goal is to get a filename and search target from the user, send those to the server through a named pipe. And the server searches for the target and sends info back.
OUTPUT:
Client: PID 2986 - Running on Tue Sep 30 20:59:28 2014 Client: PID 2986 - Enter File Name: largeSampleText.txt Server PID 2988 - Running on Tue Sep 30 20:59:32 2014 Server: PID 2988 - Synchronized to Client.//This means the client-to-server fifo is working There was an error opening serverToClientfifo//This means client couldn't open the server-to-client fifo error is: 2//This means the fifo doesn't exist yet
[Code] ....
CORRECT OUTPUT:
Client: PID 2542 - Running on Tue Sep 30 20:58:44 2014 Client: PID 2542 - Enter File Name: largeSampleText.txt Server PID 2557 - Running on Tue Sep 30 20:58:54 2014 Server: PID 2557 - Synchronized to Client.
[Code] ....
RELEVANT CLIENT CODE:
int main() { char requestedFileName[1024]; //Get initial information on the client pid_t clientPID = getpid(); time_t currentTime = time(0); char* stringTime= ctime(¤tTime);
[Code] ....
I tried creating both of my fifos in my client and my output changed to this
Client: PID 3150 - Running on Tue Sep 30 21:23:17 2014 Client: PID 3150 - Enter File Name: largeSampleText.txt Client: PID 3150 - Enter Target: Server PID 3153 - Running on Tue Sep 30 21:23:21 2014 was Client: PID 3150 - Input File >>>largeSampleText.txt<<< Client: PID 3150 - Target >>>was<<< Client: PID 3150 - Synchronized to Server Server received unexpected connection message Message: was Terminating
So It appears like the client went ahead and put `requestedFileName` and`requestedTarget`into the pipe and the server read out `requestedTarget` instead of the connection message. Not sure why though
I am having trouble with string statements in general. But the biggest problem I have is that my assignment requires that I make a grocery list with a function that uses string statements. I have all the variables and functions other than the string working. But i need a basic outline on the receipt. NO specifics! I just need a basic outline more than our teacher has given us. Also I have searched for other programs using receipts but they used vectors and my class is not into that yet how vectors work yet so I am avoiding using them.
From some other code i am calling some function in c# through windows service. That function is going to delete some unwanted data from sql server database. if i wanted i initiate the request it will take 30 min to delete the data.
in this 30 min time i am unable to access other pages in my website. is there any better way to design this?
I'm working on a program using class booktype... to hold information about various books that I have saved on a txt file. Each object of the class book type holds the author, publisher, ISBN, number of copies in stock.
I am still very much new at c++ and not exactly sure how to get in info from the file I've made earlier..
Code: #include<iostream> #include<iomanip> #include<string> #include<cstring> #include<fstream> using namespace std; class bookType {
Also the text file is formatted where after I've entered the author's name I then hit return, then publisher then I hit return, ISBN then return, and so forth does that effect the program? As for my txt file this is what I have
Code: Moby Dick Sebastian Armesto Oberoson Books Ltd 0001 201 The Scarlet Letter
I am working on my final project for my intro to c++. Its a simple program where you buy a car, choose parts for it, see the price of it in total, buying option, and to view past records.
So my problem lies with displaying the records. For some reason(doesn't many how many records there are) the very last record displays again without the "Model" part, but displays the rest of them fine. In other words, there are 2 problems, the last record is displayed twice, 2nd that added record displayed is missing the "model"(this problem doesn't matter really if you can solve the first problem, but would still like to know why it does that).
I tried debugging it and I believe the problem lies with the --------while(fName.good()). It just decides to repeat it again even though in the text file, it does not have that extra record.
Below is a snippet of my code in which it loops through a file trying to find the matching record of a selection given by the user. I use tellg() to tell me where the search begins and it does in fact start at the beginning. But when the search actually executes, it starts at the last record, loops once, and ends, as it does not find the matching record (when the user enters '24' for example)
void Hardware::updateExistingRecord(ofstream &addRecordInfo, ifstream &updateRecord, Hardware &_records) { //selection on which field to update enum Field { RECORD_NUMBER = 1, TOOL_NAME, QUANTITY, COST, EXIT }; cout << "Enter record number you would like to update "; cout << "Enter zero to exit ?";
I have been searching through the forums and found a couple snippets of code and from that i came up with this. What i want to do is search for the specific movie code and then update the movie status from inactive to active (for argument sake).
Code: #include <stdio.h> #include <stdlib.h>
typedef struct SYSTEM_MOVIE{ int movie_code; int movie_dur; char movie_title[25];
I dont know how to modify the previous record that i have done in the Add Student function. i searched from different sites and got this code for modifying a record in a text file. But, i cant figure it out why its not working.
I'm still learning intro to C language. Currently I'm having problem with my code. The task is to ask user to input information about staff and write them into a text file. The problem occur when:
1) output in text/.exe file display random characters.
2) Data obtained from New_Staff unable to pass into Export_Profile.
3) a new output will overwrite the existing information in the text/.exe file
4) the delete function unable to delete correctly after the first time i delete a staff information in text file.
I am running a little business on the side, any program I could use that will show me the balances of clients after withdrawals, deposits. For example, if i had a data file like this :
Code: e 5 Elden c 3 Felipe 55342.51415 e 3 Leonardo e 1 Yong
[Code] ....
Lines beginning with 'e' will have an integer employee ID and an employee name. Lines beginning with 'c' will have an integer customer ID, customer name, and a floating point account balance. Lines beginning with a 't' will have a customer ID, employee ID, a 'w' or 'd' representing withdrawal or deposit, and a floating point transaction amount.
Now, obviously the program doesn't have to be exactly like this but something along these lines.
You are given an integer, perhaps a very long long integer, composed of only the digits 1 and/or 2. You have the ability to change a 1 digit into a 2 and a 2 digit into a 1 and must determine the min. number of changes that you can make resulting in no 2 digits remaining in the number that are in a position(in terms of powers of ten) higher than any 1 digit.
example:
2222212 number of changes:1 1111121 1 2211221 3 1122112 2
no negative numbers.
how to get started. Also I'm not allowed to use anything related to arrays or sorting.
I want to make an encapsulated surface class that keeps track of important aspects about a surface. I have it started, except when I test the .onDraw() function, nothing appears on the screen. My Code is below:
I want to know how to respond to a request made by a mobile application (preferably Android) through a desktop software. So for example if there is a button on the mobile app named 'do something and a user clicks it, I want the desktop software to respond to that request and 'do something
So what I was thinking was to upload a file to a server when the button on the app is clicked and add a timer to the desktop software to connect to the server and read the file and respond accordingly.
Is this how it is usually done or am I going about this the wrong way? Im developing the app in C# (Xamarin) and the desktop software in C# as well.
implementing a game of chess, i was able to easily implement the grid with an 8x8 multidimensional array.but here is the case I need to implement a grid made of hexagons(six sided but in future may be seven sideded or eight may be needed): like a beehive something.
How can such a grid be implemented in c++ taking notes of coordinates and borders and stuff? From where i can start working from? this grid has to be just like the chess grid only we got six sided boxexs instead of four,
Is it possible in C to instantly react to keystrokes made in console?For example, consider the following code:
Code:
#include<stdio.h> int main(int argc, char *argv[]) { char ch; printf("Enter a sentence... ");
[code]....
The evaluation of the if statement inside the loop will not occur until the Enter key is pressed on keyboard.To my best understanding, It just pushes the keystrokes to some buffer, and when the '' is introduced, it evalutes the characters one by one.Is there an elegant way to instantly react to keystrokes in C?