I'm intrested in creating programs of games and such which learns while playing and saving the information for further use. For example a tic tac toe game where the program saves evry game it won or lost and creates a tree of some kind that store the information of the game and save it in a file when the program is being quit. The problem i'm having is how to save a tree in a file efficently.
I'm trying to make a program that you input your login info and it writes that info to a text file. Then, later on once I get my problem fixed, the program will read the info to the user. my code is as follows(the input part is a bit lengthy):
I need to transfer the content from the file text.txt to file sort.txt . The data in the text.txt is "struct" (info about people)but the same data needs to be sorted by the name and sent to sort.txt by using a function .
I am looking for a way that I could check the information of a folder and a drive, to show the data size and storage amount (KB, MB, GB). This is so that I can compare the size of a folder to the storage capacity of a disk drive.
I'm trying to open a text file with the name "text.txt", for the purpose of only displaying in the console an specific part of the text file. For example, if I got "This is a test [TEXT] This is the message that should display [/TEXT] this is the end of the file", I want only "This is the message that should display" to be the output, the thing is that I can't imagine anyway of doing that. what I should do?
I'm a beginner at programming and I'm not sure how to read in information from a text file. What I want to do is take a text file which contains around 20 rows and 3 columns of numbers, and put these into an array which can then be used for performing calculations. How do I do this? Would I need to declare the size of the array beforehand? When accessing my file, do I include the full address?
The relevant part is lines 29-33:
Code: #include <stdio.h> #include <stdlib.h> #include <math.h> /* this is a simpllified code using BEM equations */ main()
Your goal is to open this struct of students (the binary file). Once open, the first job is to print out each student. Afterwards, display all students with a gpa of 3.5 and higher. Finally, display all students with the major of Computer Science or Game Programming. Be sure to title each category of items.
He gave us a .cpp file and a .h file that we're suppose to use to run the program. He doesn't want us to change his original code, except we can add the needed code to run his code (i.e. Struct & Main).
My problem is that I get an Abort() crash message in VS2013 when I try to run it. Now, in line 95 of the cpp file if I replace the char* with "", it runs fine showing the GPA with blank entries for the other print parameters. I've read the Binary Files chapter of the Pearson textbook several times and it doesn't have anything to say about working with char pointers.
Header file:
#pragma once //Professor's code struct StudInfo //Start of my code { char* fName; char* lName; char* major; double gpa;
I have a tab separated file that consists of 10 columns. (classical txt file).the third column is the one interesting to me it consists of some strings like :
according to the value in the third column i wish to split my text file sot that i have files string1.txt string2.txt and string3.txt such that each file contains the whole line. how to do it in c++ with hash tables (maps) and all those fancy tools all ready and waiting for me to use them but in c i am crippled.
My idea was to first go through the file, hash all values in tht third column so i get a unique set of elements and then for each distinct string(element) in the third column create a file pointer, then go once more through the file and as I encounter a specific string(element) type, write the whole line into the appropriate file.
I have a program that gives the user the option to create an employee ID, name, address and so on. It also has the option to search employee by employee ID.
What I want to know is how to add and replace employee info. For example employee changes address. Also how to delete employee information from text file.
Here's my code:
//This program uses file input and output for an employee information system. #include <iostream> #include <string> #include <fstream> using namespace std; int main(){ ifstream inFile; //declare ifstream as inFile and ofstream as outFile ofstream outFile;
I'm having trouble in getting my program to read from a file and put all the proper data into its proper class variables. I have a class (called Champion) that has string variable for a name and a vector of strings for items. I also have a vector of Champion that holds multiple champions. Here's my code:
I know how to save/open files but im just confused on where to write the code for it in this block of code :
#include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; const int NUM_MONTHS = 12;// Number of months const int NUM_CATEGORIES = 6;// Number of categories
Right now I'm working on an assignment where I need to take the data from on file encrypt it by adding 5 to each byte and then save it to a user specified location. I think I'm close to having it done but I've run into a hick up. After I get the user input for where the encrypted data should be saved the program seems to never end. This is the code I have so far
#include <iostream> #include <fstream> #include <string> using namespace std; int main() { ifstream input; ofstream output;
I'm trying to read information from a file and put the data into vectors of its appropriate type. For example: the file will have an int ID, string firstname, string lastname, double salary, int hours_per_week, and string work_position. All this data is separated by ";". I don't know how to read this file into the appropriate vectors: vector<int> ID, vector<string> fname, vector<string> lname, vector<double> salary, vector<int> hpw, vector<string> work.
I am trying to use a combination of windows batch scripts as well a C++ program to put users data into one single .CSV file. Right now, I have a batch file that will output data from the command line into multiple .txt files. These files are mac.txt, serialnumber.txt, computermodel.txt, and computer name.txt. What I want to do, is to have users run the batch file, which will in turn run the .exe C++ file which will concatenate all their data into one file, computerinfo.csv. The file format for this file would be to have the mac address, serialnumber, computer model, and computer name all in their own column.
My main issue is that these individual files don't have the format that I would like, but based on the command prompt functions, there isn't really any good format. For example, the mac.txt file has the following format:
Physical Address Transport Name =================== ========================================================== xx-xx-xx-xx-xx-xx DeviceTcpip_{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} yy-yy-yy-yy-yy-yy Media disconnected zz-zz-zz-zz-zz-zz Media disconnected
but all I really want is xx-xx-xx-xx-xx-xx
The other files have other issues with format, but if I can figure out this one then the others should be a piece of cake.
Also, I want the output of this to all go in one row, and as other users run this file, they will go into new rows without touching the rows above.
What I want to do is create a file that will ask the user to enter his info,n then store it in a text file The screen will ask the user if he wants to update his info. if he says yes then the screen will be cleared and the old info will be printed on the screen. The user will enter his new info that will be stored in a new file. My problem is that once the user finishes entering his input the program just closes D: and the rest of the program won't run.
Code:
int main() { string ans; ofstream Xfile("original.txt"); cout <<"Enter your name and address please"<<endl; cout<<"Press Ctrl+Z+Enter when you are done"<<endl; string name_and_street;
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;
My project involves writing a c program to generate a set of 70 decimal numbers. I want to save the output (these 70 numbers) as a txt file. I tried the following:
1. prt scr of output screen and pasting it in notepad. NOT WORKING 2. going to DOS SHELL and doing the following: c:TCBIN>output.exe>>output.txt NOT WORKING. Text file is generated, but it does not contain output. It just says: illegal command: output.exe
Interface class Person{ private: char name[80]; short age; public: void get_data();
[Code] .....
This is a simple example from and old Lafore C++ book, with a few tweaks by me. The point is simple. Save object person to a *.dat file, exit the program, then start up program again, open up *.dat file, and load contents.
The first problem is the compiler is printing a bunch of Asian characters to the file (is this normal?)
The second problem is, it's not loading the object as it should, giving me a bunch of gibberish.
I have been working a while with saving and retrieve structs, and I still have not got it to work. I get Segmentation fault sh "${SHFILE} . I have search this error, and it has something to do with memory, but what, since I am a beginner with saving and retrieving files. The project runs fine, and the error stated above outputs into my console window as text.
I started with C# 2 days ago, but i have made 3 "games". Its something like Cookie Clicker, very simple and very easy.
But I have problem with saving the game. I want to save values of variables to text file when i click on button, and when i click on another button i want to values of variables load. Just simple save system. How it works and so.
I'm very new to c and c++ and am currently working on a Caesar cipher that grabs encrypted text from a txt file and decrypts it onto a new txt file. My code builds fine in CodeBlocks and when I run it, there is a new txt file created but it stays blank.
#include <iostream> #include <fstream> #include <string> #include <stdlib.h> #include <cstdlib> using namespace std ; int main(int argc, char *argv[]){