C++ :: Library Program To Add Information About Books In Binary File

Jan 3, 2015

I am working on binary files in turbo c++ 3.5 and i want to create a library program. I want to add information about books in a binary file and do functions such as: Search and replace, delete a record, and etc.

I do this functions but i have 2 problems: 1. For example when i add 6 records about books to file, BooksReport function cant show all records and for example just show 4 or 5 records and when i search records, from 5 records, for example i just found 3 or 2 records. 2.When i search and replace a word on file, all records thats before this edited record, will be deleted.

#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void add();
void search();
struct {
char name[20];

[Code]...

View 2 Replies


ADVERTISEMENT

C/C++ :: Segmentation Fault With GDB Result Change Information From Binary File

Jan 4, 2015

I'm trying to change some information from binary file but I get segmentation fault. Suppose there are two teams which names are same. The names are wanted to change. But, I get segmentation fault.

team_name, city , stadium ,fdate, colors
the team is in binary file
manunited,manchester,old_trafford,1878,black-rd
chelsea,london,stamford_bridge,1905,blue-whte
manunited,manchester,old_trafford,1878,black-rd

[Code] ....

View 4 Replies View Related

C++ :: Program That Ask User To Input 5 Books With ISBN Title Of Book With Author

Jan 29, 2013

So I was asked to create a C++ program that will ask the user to input 5 books with the ISBN, Title of the book and author/s. It will ask for 3 authors, if the book has only one author, you should leave "author 2 and author 3" blank and display only one author. Thing is... I'm having a problem with the if else condition at the last part of my program. I cant seem to make it work.

#include <iostream>
#include <cstring>
#define SIZE 5
using namespace std;
int i;

[Code]...

View 9 Replies View Related

C/C++ :: Reading Books Saved In DAT File And Inserting Them Into Linked List

Mar 13, 2015

I'm having a problem in my Library assignment, this section of my code is for reading in books saved in a 'book.dat' file on my desktop and inserting them into the linked list. It kind of works, but say if there is two books in the file, it only saves the second book twice.

eg in book.dat:
123 book1 Tolkien 2009 0
111 book2 Rowling 2009 0

So once these are read in, and I call my method displayAll(), it would display the second book twice..

void importFromFile(FILE *fp) {
struct book *aBook;
struct node *aNode;
aBook = (struct book *)malloc(sizeof(struct book));

[Code] .....

View 6 Replies View Related

C++ :: Program Won't Output Any Information To Text File

May 6, 2013

my program wont output any information to the text file that I have specified it just creates it but it leaves it blank

#include <iostream>
#include<string>
#include<iomanip>
#include <fstream>
using namespace std;
class Carloan

[code]....

View 2 Replies View Related

Visual C++ :: Program That Get Information From DAT File - Unresolved Ecternals

Mar 10, 2014

I am writing a program that grabs information from a .dat file. I have the code all structured up, but I get these 2 errors that does not make any sense to me on how to fix the program.

errors (2):

Code:
Error1error LNK2019: unresolved external symbol "void __cdecl swap(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,class std::basic_string<char,struct std::char_traits<char>,
class std::allocator<char> > *)"

[Code] ....

Error2error LNK1120: 1 unresolved externalsC:UsersMomDesktopDriveQuarter 2C++ProjectsDynamicDeptPayrollDebugDynamicDeptPayroll.exeDynamicDeptPayroll
.dat file contents:

Code:
Fogarty Bob 1 40 10.25
Smith John 2 38 8.72
Jones Mary 2 28 6.25
Arrmen William 1 15 8.22
Lavey Betty 1 32 15.00
source contents:

Code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
//PROTOTYPES
void sort(int n);
void swap(string *p1, string *p2);

[Code] ....

View 2 Replies View Related

C++ :: Program Crash Writing To Binary File

Feb 17, 2014

cant write to binary file

#include <stdio.h>
#include <stdlib.h>
typedef struct {
int number;
} something;
void main() {
int numbers[10]={1,2,3,4,5,6,7,8,10,12};

[Code] .....

View 2 Replies View Related

C :: Compute Total Price Of Books By A Given Author

May 7, 2013

Given a structure book defined as follows and an array lib of books

Code:
struct Book{
char title[100];
char author[100];
int price;
struct Book *nextedition;
};

struct Book lib[1000]; I'm going to write a function to compute total price of books by a given author including all books which are future editions of his book, even if the author of that future edition is NOT the specified author. title author price nextedition Book1 Author1 25 &lib[2] Book2 Author2 20 NULL Book3 Author3 30 &lib[3] Book4 Author1 35 NULL
For the example above, given the author "Author1", the function should return 90 (=25+30+35), and given the author "Author 3", the function should return 65 (=30+35).

So here's my attempt:

Code:
int totalPrice(char author[100]){
int total=0;
for (i=0; i<numbooks; i++)
if(strcmp(author, lib[i].author==0))

[Code] ....

What I'm trying to do is finding the first book in the lib of the specified author using for loop and then let the while loop do the rest. However, it seems the price is over-counted after each iteration of the for loop but I don't know how to fix it.

View 2 Replies View Related

C :: Binary File Write By User Input Then Printing Binary File Data Out

Dec 6, 2013

Following is the program I wrote it basically takes 9 inputs and then save them into binary file. then print out the data stored in binary data and find inverse of it then print the inverse out. but its stuck in a loop somewhere.

Code:
#include <stdio.h>
int main() {
int a[3][3],i,j;
float determinant=0;
int x;
FILE *fp = fopen ("file.bin", "wb");

[Code] .....

View 6 Replies View Related

C :: Program To Read Binary Data And Print It - File I/O Error

Mar 14, 2013

Objective of this program is to read binary data from a file and print it.

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

[Code] .....

But When I Run This Code First It Print "Error." Then Rest Of The File.Say In My File I Have "I AM HUMAN", It Prints "Error. HUMAN"!!

I Cant Figure Out Whats Wrong In The readFile() Function.It seems right to me.

View 4 Replies View Related

C++ :: Program That Inputs A File / Performs Binary Division And Outputs Remainder

Sep 30, 2013

For class I need to write a program that inputs a file (the dividend), performs binary division on the file (using 0x12 as the divisor), and outputs the remainder(checksum).

I have researched binary division algorithms and I get the general gist, but I'm still unsure where to start. How would I store the dividend and divisor? As two arrays of bits?

Then, I need to figure out how to perform shifts and XORs on the the binary numbers. Maybe I should use bitwise operations?

View 5 Replies View Related

C++ :: Multiple Quiz Program - Adding High Score For Each User Stored In Binary File

Jul 11, 2014

I am making a multiple quiz program. So everything is working fine, except for the part where i'm trying to add a highscore for each user which is being stored in a binary file. I have added a sample of the program containing the error. This isn't the actual program, which is very long.

class user { //The collection of all info pertaining to the users
char user_id[50];
public:
int hscore1;
user() {
strcpy(user_id,"NULL");
hscore=0;

[Code] ....

View 1 Replies View Related

C :: Program That Saves Information On Memory

Jun 25, 2014

I am doing a program that saves information on the memory and then i need to put by ascending order the student number.. but i can't get it to work...i tried with strcmp but not worked...

Code:
typedef struct {
char name[100], email[100], adress[100], postal[100], number[20];
int phone
}data; t

Then i have this to input data

Code:
void add(data* contact) {
if (i<total) {
printf("
Name: ", i + 1);
fflush(stdin);

[Code] ....

View 13 Replies View Related

C++ ::  Program To Grade T Or F Test Not Outputting Information

Jul 2, 2014

I wrote a program to grade T or F test. It is running, but not outputting the information.

Code:

#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
using namespace std;
double grading(char*answer, char* stuResponse, double graded);

[Code] ...

text doc:

TFFTFFTTTTFFTFTFTFTT
ABC5403 TFTFTFTT TFTFTFFTTFT
ABC5404 TFTFFTTFFTFFFTTTFTFT

View 5 Replies View Related

C# :: Program Won't Accept Database Information Using Parameters

Apr 30, 2014

I am creating a WinForm registration application and my program accepts user input information and stores it but I am struggling to use my login function. I believe there is an error in the area of cmd.Parameters.AddWithValue section, I dont think addwithvalue is correct ? I get a fatal crash has occurred when I click Login

string constring = "datasource=127.0.0.1;port=3306;username=root;password=welcome";
string Query = "SELECT * FROM 'userinfo'.'users' where 'username' = @userid and 'password' = @password)";
MySqlConnection conDatabase = new MySqlConnection(constring);
MySqlCommand cmd = new MySqlCommand(Query, conDatabase);
cmd.Parameters.AddWithValue("@userid", this.userid_txt.Text);
cmd.Parameters.AddWithValue("@passone", this.passone_txt.Text);

[code]....

Fixed the crash error, simple typo but now I am getting SQL Syntax errors which I originally believed I fixed.

View 1 Replies View Related

C/C++ :: Program That Accepts Information And Calculated CGPA

Jan 30, 2015

i want to display the grade report of two students in the table but this code will repeat the grade report of one student in the tables and what is wrong with this code below ?

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

[Code]....

View 3 Replies View Related

C :: Send Information And Receive From External Command Prompt From Program?

Jan 10, 2014

How can I send information and receive from external command prompt from my program??. I want to run an external command prompt, a code that's is not mine, to send information to this command prompt, then make my program hit enter at the command prompt and then receive back information from the command prompt.

View 5 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

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

C :: File Process - Delete Or Update Information

May 18, 2013

i have written a student information storing program. it has add,delete,list,and update menu (in program i have written update == uptade,i know : P )

my question is i cant delete or update the information. where is my failure ?

Code:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#define max 3
struct og {
char id[12];

[Code]...

View 2 Replies View Related







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