C :: Updating Record In Random Access File

Nov 5, 2014

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];

[Code] ....

View 1 Replies


ADVERTISEMENT

C :: Search A File For Specif Data And Update It (random Access)

Nov 9, 2014

The file name is "movie.dat" and currently i was able to save data into the file in this order:

[movie_code] [movie_dur] [movie_title] [movie_rating] [movie_dir] [movie_genre] [movie_status]

[12345] [120] [Movie] [PG13] [Director] [Comedy] [Active]

I want to search for the "movie_code" and change the [movie_status] from Active to Inactive.

So lets say for example i have a movie code 12345 saved in my movie file. I want to change the value from "Active" to "Inactive"for argument sake.

This is the code i was trying to do it with:

Code:
FILE *movie_fp;
movie_fp = fopen("movie.dat", "r+b");
int m_code;
MOVIE movie_data;
printf("*** Welcome to the movie updater! ***

[Code].....

View 3 Replies View Related

C++ :: Random Access Iterators

May 20, 2013

In this code:

vector<int> mydata(100);
mydata[2] = 999;

In statement 2 does that call the iterator to access the 3rd position and set its value to 999?

View 18 Replies View Related

C/C++ :: Updating Values In Dat File

Nov 9, 2014

The file name is "movie.dat" and currently i was able to save data into the file in this order:

[movie_code] [movie_dur] [movie_title] [movie_rating] [movie_dir] [movie_genre] [movie_status]

[12345] [120] [Movie] [PG13] [Director] [Comedy] [Active]

I want to search for the "movie_code" and change the [movie_status] from Active to Inactive.

So lets say for example i have a movie code 12345 saved in my movie file. I want to change the value from "Active" to "Inactive"for argument sake.

This is the code i was trying to do it with:

FILE *movie_fp;
movie_fp = fopen("movie.dat", "r+b");
int m_code;
MOVIE movie_data;
printf("*** Welcome to the movie updater! ***
");
if(movie_fp != NULL){

[Code] ...

View 2 Replies View Related

C :: Updating Specific Data In The File

Mar 17, 2013

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define MAX 200

[Code] ....

Inside of my studentinfo.txt file

Code:
Jnh Has 2353325 23 56 72 34 67 22 46 42 5 23 56 23
Daniel Laurent 6744590 10 20 30 40 50 60 70 80 90 100 40 50

This code is working totally fine. Right now, I'm trying to update a specific data from the student info. Let's say I'm trying to update my student number of Daniel. So, in this case, I want to replace 6744590 to some other student number. I think I have to use fseek() or rewind() and use fputs() but, I don't know how I should decide where to look.

View 8 Replies View Related

C++ :: Student Registration System - File Updating

Feb 14, 2012

I have been creating this program for a student registration system. For the file handling So far I can write in to a file , view all records, and search a single record. now i got the problem with updating details . my coding is as bellow ..

void file_update() {
int r;
struct student stu;
fstream stu_file;
cout <<"========Update Record======"<< endl;
stu_file.open("student.txt", ios::app );

[Code] ....

My problem is it won't update the record. it just adding a new record.

View 9 Replies View Related

C++ :: Program To Extract Numbers From A File That Is Always Updating With New Data

Mar 14, 2013

How to write a C or C++ program that extracts certain numbers out of a section after the 4, 5 and 6 space.

For Example:

The output file will produce:

[ [1900 00 0 -2.000000 0.650000 0.006000 0.020000 2.274000 0.010000 54 0 0.7 10.8 1 0 0 0.000000 17.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 18];...

So I want to extract the numbers 0.650000, 0.006000, 0.020000 because those are the 4,5,6 space after [ [

Another problem I have is that the output file I showed will always being updated constantly for instance as follow:

[ [1900 00 0 -2.000000 0.650000 0.006000 0.020000 2.2054000 0.010000 10 0 0.7 10.8 1 0 0 0.000000 17.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 13];...

[ [1900 00 0 -1.000000 0.650000 0.006000 0.020000 2.694000 0.010000 9 0 0.7 10.8 1 0 0 0.000000 17.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 10];...

[ [1900 00 0 -2.000000 0.6023000 0.04000 0.050000 2.2454000 0.010000 5 0 0.7 10.8 1 0 0 0.000000 17.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 12];...

And it will keep updating like this and I want to update the previous numbers I extracted with now the new numbers after the 4,5, and 6 space.

So I have to write a code to let it know when it encounters [ [ start looking for the 4,5,6 space and get those numbers and once it reaches ;... that's the end of that section so re-look for the next section of numbers after the 4,5,6 space.

The file will be a text file or matlab file that is always being updated with these sections of numbers. Can I make this a #include<nameoffile.h> or does .h not work with a file that is always being updated.

View 2 Replies View Related

C++ :: Header File That Is Continuously Updating To Extract Certain Variables?

Mar 10, 2013

I need to write a C++ program, that extracts certain variables, x y z, from a file that is continuously being updated x y z. These variables are going to be used to recalculate a new answer.

My question is to see if it is possible to have an include .h file that is always being updated so that I can extract these three variables from it, and always have the newest venison of each variable, so that the answer to the equation is always the newest updated. Should I use fopen or fwrite to do this.

View 4 Replies View Related

C++ :: Reading From TXT File That Is A Record

Apr 18, 2014

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

[Code] ....

View 6 Replies View Related

C/C++ :: Reading In Record In Text File Twice?

Dec 1, 2014

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.

//inventory
void viewInvent(string fName)
{
//variables

[Code]....

View 3 Replies View Related

C/C++ :: File Search Not Starting At First Record

Aug 10, 2014

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
?";

[Code] ....

View 10 Replies View Related

C/C++ :: Delete Record From Binary File?

Jan 12, 2013

How To Delete A Record From binary File - C++ ?

View 1 Replies View Related

C :: Student Record System / File Handling

Feb 25, 2013

Code:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
}

[code]....

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.

View 2 Replies View Related

C :: Record Data (add / Delete) In Text File

Aug 24, 2013

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.

The code is as follows:

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

void Menu();
void New_Staff();
void Delete_Staff();
void Export_Profile();

[Code] ....

View 4 Replies View Related

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();

[code]....

View 1 Replies View Related

C/C++ :: How To Create Function To Delete Record Of Binary File

Aug 17, 2013

I want to create a function to Delete , Edit record of Bianry File in C++, I have tried again and gain but not success .

View 1 Replies View Related

C++ :: Data Structures - File Size Not Decreasing When Erase A Record

Nov 26, 2014

// my size is not decreasing when I erase a record.
//dvr_hwch.cpp

#include <iostream>
#include <iomanip>
#include <cassert>
using namespace std;
#include "hash_chn.h"
void print_menu( );

[Code] .....

View 1 Replies View Related

C++ :: Create File With Given Size And Then Randomly Access File To Populate It

Feb 17, 2015

I am interested in creating a file of a given size and then randomly accessing the file to populate it. Is there a way to quickly create, for instance, a 4 GByte file in C++, initially populated with garbage?

View 4 Replies View Related

C++ :: Access Private Data Of Base Class Without Access Modifier

Sep 9, 2013

if we don't provide the acces modifiers for base class and we need to manipulate the private data of base class in derived class. Is there anyway to acces the private data members? Here's a coding example

class A {
private :
int a;
};
class B : public class A {
public :
void displayA() { cout<<a<<endl; }
};

how i can acces the a of base class A in derived class B without acces modifiers.

View 16 Replies View Related

C++ :: How To Access File Properties

Jun 29, 2014

Is it possible to access file properties from c++ program? For example, user could drag file to program and then it displays a detailed information about file like date modified, size, type and etc..

View 1 Replies View Related

C :: How To Access Name And File Name Members

Sep 8, 2014

How to access the name and file name members on line 42 and 43?

Code:

typedef struct {
char * name;
char * filename;
} FILES;
FILES * files[256];
}

[code]...

How to access the name and filename from within function?

*files[count].name = chTmp;

View 9 Replies View Related

C++ :: How To Access A Method Form CPP File

May 21, 2013

How to access a method from a .h file in another .cpp file

Code:

// main.cpp

#include <iostream>
#include "inc/one.h"
using namespace std;
int main( ){

School Tadd;
Tadd.AddTeacher(1);
return 0;

[Code] ....

When I compile , i am getting the below error

In function main:
undefined reference to `School::AddTeacher(int)'
Build finished: 1 error

View 4 Replies View Related

C# :: Blocking File Action Access?

Apr 20, 2014

My problem: I want to make an application that is going to block the action of some files (It is anticheat files actually).

how do I make code to block the application's action?

Maybe there is another way to do that? I need to use Cheat Engine in game, and anticheat blocks it, so I thought if I'll block the activity of the anticheat it couldn't detect the Cheat Engine...

View 2 Replies View Related

C/C++ :: Access Variable Using Extern In A Particular File

Sep 2, 2013

I have 3 files: f1.c f2.c and f3.c

I have declared variable int a; in f1.c and int a; in f2.c.

Now I want to use the variable int a; in f3.c . But this variable corresponds to the variable in f2.c .

View 4 Replies View Related

C++ :: Access Variable Updated In One To Another CPP File?

Dec 18, 2012

I have two cpp files.I m updating a value of an integer in one cpp file and i want to perform a specific function in the second file as per to the value updated in the first file. ie I m initialing the variable in the constructor. I have two buttons in the first cpp file. On clicking the first button I m updating the variable as 1 and on pressing button two , I m updating the variable as 2. I m retrieving this variable in the second cpp file with respect to the object created for the class in the first cpp file.

The problem is that i m not able tot retrieve the updated value in the second file. only the initialized value is being retrieved. neither 1 nor 2 is updated.

View 3 Replies View Related

C# :: SQL Update Not Updating But Can Add - No Errors

Feb 1, 2015

I am currently just trying to update a record in a SQL database.I can add a record and delete a record just fine but when I go to update I get no errors but it just doesn't update.

Here is what I have and done coding for hours trial and error

private void btnAddProd_Click(object sender, RoutedEventArgs e)
{//validate method // product = new Product(txtProductName.Text, Convert.ToDecimal(txtProductCost.Text), txtProductType.Text);
product = new Product();
MakeProduct(product);
if(modify) {
Product theOneAndOnly = new Product();

[Code] ....

View 1 Replies View Related







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