C++ :: Airport Reservation Program - Binary Files Comparing

Aug 18, 2014

I am working on a airport reservation program and i have run into a brick wall. i want to ask the user its name, gender, passport no, age, destination, and travel class and figure out the day and flight code of the flight which i have saved in a binary file. now every thing works fine except the code and the day.

The programs important section

the flight class Code:
class flights {
char code[9],location[21];
public:
void display();
char *retloc() //to get the Location

[Code] .....

View 13 Replies


ADVERTISEMENT

C++ :: Airline Reservation Simulator - Binary File Errors

Aug 11, 2014

For a big project for school I have to make an airline reservation simulator but I have run into a problem. I want to save the the flight code and its location in a binary file so that I can obtain a code according to the location but this happens:

[URL] ... (link to current output and expected output)

Here is the source class

class file {
private:
char code[8];
char from[20];
public:
void input();

[Code] ....

View 4 Replies View Related

C/C++ :: Train Reservation Program - Declaration Terminated Incorrectly

Dec 8, 2013

//PROGRAM - TRAIN RESERVATION
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
#include<stdio.h>
#include<fstream.h>
#include<process.h>

[Code] .....

View 1 Replies View Related

C++ :: Comparing Two Data Files?

Feb 15, 2013

I'm trying to compare two data files character by character to see if they are the same. If the files are different, the program should print out the line numbers of where they do not match. So far, I have the part where it returns 'T' for when the files are the same and 'F' when they are not. But how should I start where the program prints out the line number where the characters are different? I am thinking of an array but nor sure how to start it.

View 1 Replies View Related

C++ :: Comparing Words From Two Different Files Using Fstream

Feb 2, 2013

I'm trying to input a html file and copy everything from that file to a new html file with some changes. I need to read the html file word by word and compare them to a file with some keywords. If a keyword matches a word in the html file then it will add italic tags around that word in the output html file. As it is now it doesn't output anything.

Logically I want to read a word from the html file and then compare it to every keyword and output the result.

fileIn = original html file
keyword = keywords file
outFile = html file writing to
std::string str;
std:: string word;

[Code]...

View 2 Replies View Related

C :: Comparing Structures From Binary File?

Jul 20, 2014

I'm wondering which method faster in comparing structures from a binary file.

Method 1:
Reading through the file one structure and a time and comparing each structure.

Method 2:
Reading numerous structures and allocating to memory , then reading through each allocated memory and comparing.

View 3 Replies View Related

C++ :: Strcmp Function - Comparing String Data From Two Different Files

Dec 20, 2013

I am having a slight issue with the strcmp function. I am comparing string data from two different files. I want the function to output a set of information if the strings are the same and a different set of data if the strings are different. My issue is, the function outputs the data that's the same but not different.

I had an else statement that compared the data if it was NOT equal but it only duplicated the data in the file.

One file is a listing of 100 books with 10 lines of information and an assigned market. The second file is a listing of the markets contained in the books file. However, the books file has a market that is not located in the markets file. The "missing" market is what is not priting or displaying.

// final project2 file

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>

using namespace std;
const int ARRAY_SIZE = 500;
const int MARKET_ARRAY = 6;
ifstream infile, infile2;
ofstream outfile;

[Code] .....

View 6 Replies View Related

C/C++ :: How To Change Seat Reservation

Jun 9, 2014

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void) {
char answer;//예약 선택
int select1 = 0, select2 = 0, i, j;//필요 변수 선언
int seat[5][5] = { 0 };

[Code] .....

well this is my seat reservation code and my program show the seats like

1 1 2 3 4 5
2 0 0 0 0 0
3 0 0 0 0 0
4 0 0 0 0 0
5 0 0 0 0 0

I want to change these numbers to "■" and "□"(when it's empty seat)

View 1 Replies View Related

C :: Program To Hide Files Behind Other Files Using Alternate Data Streams

Apr 5, 2013

I am writing a program to hide files behind other files using Alternate Data Streams in Windows NTFS file systems.

The program is as follows:

Code:

#include <stdio.h>
#include <stdlib.h>
int main(void){
char hostfile[75], hiddenfile[75], hiddenFileName[15] ;
printf("Enter the name(with extension) and path of the file whose behind you want to hide another file: ");
scanf("%75s", hostfile);

[Code]...

The complier is showing error as "Extra Perimeter in call to system" but I am not getting where?

View 4 Replies View Related

C++ :: Airline Reservation - Assign Seats On Each Flight

Jun 24, 2013

A small airline has just purchased a computer for its new automated reservation system. you have been asked to program a new system. Develop a program to assign seats on each flight of the airline's only plane (capacity = 10 seats) your program should display the following alternatives

Please type 1 for "SMOKING"
Please type 2 for "Non-Smoking"

if the person types 1, your program should assign a seat in the smoking section (seats 1-5). If a person types 2, your program should assign a seats in the non-smoking section (seats 6-10). your program should then print a boarding pass indicating the person's seat number and whether it is in the smoking or non-smoking section of the plane.

Use a single-subscripted array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seats is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available.

Your program should never assign a seat that has already been assigned. When the smoking section is full, your program should ask a person if it is acceptable to be placed in the non-smoking area section ( and vice versa ), If yes, make the appropriate a seat assignment. If no, print the message " Next flight leaves in 3 hours! ".

View 5 Replies View Related

C :: Making Program For Comparing Strings

Oct 16, 2013

I know there is a function for comparing string but i am making it to just improve my concepts.error : 2 is coming as answer when i put same sting in both place.

Code:

#include<stdio.h>
main()
{
char str1[] = "hello" ;
char str2[]= "hello" ;
int q;
q = xstrcmp(str1,str2);
printf("%d",q);
}

[code]....

View 5 Replies View Related

C++ :: How To Read Binary Files

Sep 20, 2014

I'm trying read a binary file. A binary files is continued with bytes(ascci characters). and the 1st position is the position 0(zero).

I'm trying read just some values from ICO file:

- the 3rd value is in 4th-1 position(number of icons); (See the table: [URL] .... )
- the with is the (numberoficons*16) + 4 (the 16 is the Entries structure size) position;
- the height is the (numberoficons*16) + 4 + 4 (the 16 is the Entries structure size) position.

now see the code:

int iconwidth;
int iconheight;
int iconcount;
FILE *iconfile = fopen(filename.c_str(), "rb");//open the file
fseek(iconfile,4-1,SEEK_SET); //put the file in position 6(the position starts from 0)
fread(&iconcount,sizeof(char),2,iconfile);//get 2 blocks with char size(2 bytes).. i'm getting the number of icons

[Code] ....

so what i'm doing wrong with block positions?

View 13 Replies View Related

C++ :: How To Merge Binary Files

Jan 5, 2013

I am attempting to merge binary files. However, this is to no avail. The program keeps segfaulting. I want to merge the buffers the files are stored in and then write the new one to disk. Anyway, here is my code.

Main.cpp:

#include "getsize.h"
long lSize;
char * buffer;
size_t result;
FILE * pFile;
FILE * pFile2;
FILE * pFile3;
void read1() {
pFile = fopen ( "uTorrent.exe", "rb");

[Code] ....

View 19 Replies View Related

C++ :: Class Objects - Program Not Comparing Two Strings

Jun 20, 2013

I am having difficulty with class objects.

1. why my program won't actually compare the two strings.
2. why and where I am having a memory dump crash.

The following is my main.cpp, String.cpp, and the header file in that order.

#include <iostream>
using namespace std;
#include "GREEN_String.h"
void main () {
GREEN_StringStr1;
GREEN_StringStr2 ("AdrianGreen");

[Code] .....

View 5 Replies View Related

C :: How To Read String From Binary Files

Sep 6, 2013

I have a structure stored in a binary file, now I want to read each string from it (or line), can I do that using fgets?

View 12 Replies View Related

C/C++ :: Reading And Writing In Binary Files?

Jun 5, 2014

why I'm giving "Access violation reading location 0x336827B8" and also I was able to read my data but it's giving me weird stuff. I want to write the sorted grades and the average in a new disk file. so here's my code so far here's my code

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int avg(int sum, int size);
void swap(int *, int *);

[code]....

View 5 Replies View Related

C++ :: Read In Binary Files Then Write To Another File

Oct 11, 2014

I would like to read in binary files, then write them to another file.

I write a code, what works perfectly, if I would like to just copy the file to another. But I want to make it a little other.

If I open a file in hex-editor I also can see the ASCII values. But I would like get the ONLY the hex values to the other file.

For example:

d5 57 4f ad 30 33 0b 4e 49 a7 05 18 c4 90 66 d8 45 ac 39 3e 7d f1 a8 02 80
14 20 90 6e 20 12 38 0c 65 4a 28 d2 80 72 04 20 a9 4a 82 84 60 6a 0b 25
59 4c 30 c8 69 c0 ec fa 36 ed 3a da b1 9a 82 02 e0 bb 7e 41 87 02 f6 10 34
eb 95 93 63 01 6b 8d e1 d7 43 c3 df 92 5d 8a ed 57 61 4e 36 07 2a d7 56 2b
b5 0e 55 83 b4 76 8c b7 61 77 0e c9 76 0c 81 1b 01 63 0c 8b 73 57 d5 6d 4c
0c c2 0d 52 45 18

How could I make it?

View 4 Replies View Related

C++ :: Reading Large Number Of Binary Files

Apr 14, 2014

Windows 7, 64 bits, Visual Studio 10.

I have a problem to read a large number of binary files, process them and store them under a new name. The program and routines go very well for 505 files. After reading 506 files, the program now refuses to read the next file. I have 16 Gb of memory and tried to close all other programs and restart the PC. it always stops after 506 files (512 files would be more understanding in a way...).

Here is my code. I have tried many things without success. This is only part of the loop that stops. The if test if (myfile.is_open() returns false by some reason. I can start the process again starting with the file that does not open and then it stops again after 506 files.

char * tfiBlock;
ifstream myfile (OrigFilename, ios::in|ios::binary|ios::ate);
if (myfile.is_open()) {
int lengde = myfile.tellg();
tfiBlock = new char [lengde];
//static char memblock [size];

[Code] .....

Clean up procedure:
delete[] tfiBlock;

Are there any limits to how many files that can be opened, or is it maybe someting to be set in the compiler?

View 5 Replies View Related

C++ :: Char Pointers And Random Binary Files

May 6, 2013

I'm new with working with random binary files. I have a class with a char* pointer stored inside of it, I also have a constructor that takes in a string (of any size) from the user. I then simply store this string into the char *. Once the string is stored in the char *. I reinterpret the instance, and I store the information into the random binary file. Everything works.

Question: Random files must know the size of the object that is being stored inside of it, so why when I enter strings of different sizes into the file, it appears to still be working. for example this is an example of the code:

class info {
private:
char *phrase;
public:
info(string n ="unknown"){
phrase = new char[n.size()+1];

[Code] ....

My point is, lets just say for example the object ETC, was some long string, this would still work for me. My question is, I don't believe each object is the same size because I allocate memory for the char pointer in the constructor.

Should I not do this just to be safe, and just use a char array instead of a pointer? (Even tho I would have set a pre-defined size for the string) or is something happening in the back to prevent this from not working?

View 5 Replies View Related

C++ :: Creating Non-text Readable Binary Files

Jun 23, 2014

I'm currently trying to create binary file will not be able to be read as texts and will contain metadata(more like image files).

But I've tried writing to .dat, .bin files in binary mode and all of them are displaying in ascii text..which I don't want.

View 3 Replies View Related

C++ :: Storing A Class With String Members Into Binary Files

Nov 17, 2014

Im trying to make a c++ program for a school project, and i need to store the information into binary files, but I'm having some problems trying to store a class with string members, for example:

class whatever{
protected:
string name;
public:
(List of functions)
}

But if I do that, my code just dont work when I write and read a binary file, but if I change the string to char array, for example:

class whatever{
protected:
char name[20];
public:
(List of functions)
}

It works good, so I wanted to know if there's some way to store a class wiht strings in binary files, or what am I doing wrong?

View 4 Replies View Related

C/C++ :: Reading Binary Files Using Fstreams - Sort Values

Dec 11, 2014

I have written in a binary file using fstream an using sort value.

unsigned shortwidth=50,height=50;
file.write((char*)&width,sizeof(width));
file.write((char*)&height,sizeof(height));

When i try to read it back from fstream again there are some symbols (binary obviously). How can i get my values back? I want to read those symbols and in a way to convert them to my old width and height values.

View 6 Replies View Related

C :: Read Enormous Binary Files (10-100GB) And Parse Their Contents Bit At A Time

Dec 5, 2013

I am trying to read enormous binary files (10-100GB) and parse their contents a bit at a time. As part of the process I need to get the size of the file in bytes. The simple solution

Code: fseek(file,0,SEEK_END);
size=ftell(file);

fails because the file size overflows the long int type returned by ftell. I need a long long int.

Is there a reasonably efficient way to do this? The good news is that it only needs to be done once. I suppose I could read it one character at a time until I hit the end and keep count, but that just seems inelegant...

View 12 Replies View Related

C++ :: Generate Two TXT Files In One Program

Apr 4, 2013

I try to write my data into two different files and i just use something like this

ofstream myfile;
myfile.open("phase 1.txt");
if (myfile.is_open()) {
for(i=0;i<M; i++)

[Code] ....

But it only generate the first file. How should i modify this?

View 3 Replies View Related

C++ :: How To Use Two Header Files In Program

Sep 17, 2013

I want to use two header files in my program. Here is exactly what I want to do.

-In the first header I have a binary tree and a structure.
-In the second file I have another functions that need to use the structure in the first header.
-I also want to use a function from the second header in the first.
-And finally I want to do actions with both headers in a "main.cpp" file that contains only int main() function.

How to include the headers in each other and in the main.cpp to be able to do the actions above?

I try to include the first header in the second one and the second one in the first header. Then I include both headers in the main.cpp file. But the compiler shows me many errors.

View 5 Replies View Related

C :: Program Reading / Writing Files

Dec 10, 2013

program that I am working on. I want to use fgets() in my program so I could handle multiple words from a text(to be able to handle spaces). I get a weird result when running the program.

Code: #include <stdio.h>
#include <stdlib.h>
//#include "kim.h"
#include <string.h>
[code]....

View 4 Replies View Related







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