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


ADVERTISEMENT

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++ :: Binary File - Replace Data At Specific Point?

Nov 28, 2014

I'm making a binary file that has 100 "empty spaces", and then I want to rewrite specific place with info, however it always writes the info at the end of the file, no matter what I try to get position before I call write() it tells me correct position...

#include <Windows.h>
#include <iostream>
#include <string>
#include <fstream>
#include <vector>

[Code].....

View 5 Replies View Related

C :: Read Specific Amount Of Data From File Until Terminating Set Is Reached

Jul 23, 2014

I wrote a code to read a specific amount of data from file until terminating set is reached. however the code does what its supposed to correctly until it reaches the 5th loop it justs stops responding. I've checked the reading file and all elements are correct in the file.

Code:
int main(void){
FILE *file1;
FILE *file2;
FILE *file3;

struct t test1;
struct t test2;

[Code] ....

Screenshot of program crashing:

Screenshot of reading file:

View 11 Replies View Related

C++ :: Object Data Not Updating Correctly

Dec 14, 2013

I am writing a program that manages a group of tool bins. This group is handled as an object that is an array of two element structures called InvBin. I initialize the bins with data from a file which contains the descriptions and initial quantities. I also have functions to add or subtract items from a bin and a function to display a report of the description and quantity of all of the bins.

The add and remove functions work correctly based on the cout statement in the functions, however when I display the report, it displays the initial quantity instead of the new quantity. In addition, when I use the add and remove functions again on the same bin, they use the initial quantity.

These are the add and remove functions and the report function from the main program.

Code:
//Adds an item to a bin
void addItem(HANDLE screen, BinManager tools, int &count) {
int binNum;
int addNum;
system("cls");

[Code].....

View 2 Replies View Related

C Sharp :: Updating String Values Into Custom Data Xml Field

Feb 23, 2014

I have a variable named Authors. Sometimes I will insert one author into the database, sometimes more than one author will be inserted into the database.

The page that performs the update is a .cs page. Here is the layout:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;

[Code]....

This definitely works for updating one author's name:

if (old.Author != Author) RequestItem.UpdateField(LibraryDocID, Editor, "Author", Author);    

I just can not nail down how to insert a string of author's names.

View 2 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 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 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 :: Scan Value For Specific Data

Dec 13, 2014

I created a program that will create a file and print a list on it. Here is the code for my program:

Code:
int controlvalue(void) {FILE *controlvalue;
controlvalue = fopen("something.txt", "a+");
/* Series of fprintfs */
fclose (controlvalue);
return 1;}

Here is an example list created by my program:

Code:
[Gifts]Candy=45
Chocolate=32
Toy=128
Robot=754
Doll=1492
Star=21
Phone=72
Skateboard=87
Frame=314
Days=365
Perfume=421

I want to get the value of "Skateboard" on file. So I need to read 9 lines. On the 9th line, the gets() loop will stop. But, what if I only want to get the value of "Skateboard" as integer (87) and not a string? Also, is it possible to scan the value of Skateboard if it's located on a different (or unknown) line?

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

Visual C++ :: Write Raw Data To USB HDD (in Specific Sector)

May 4, 2015

I can access a physical device to read a specific sector in a USB hard drive. But my question is how can I Write to a specific sector? Lets say I want to replace what is in a specific sector of a hard drive with a new data.

View 6 Replies View Related

C# :: How To Link Data To A Report Viewer On Specific Event

Jan 31, 2015

I created a dataset that contains an empty dataTable that has several columns , and then I created a new report that is linked to this datatable using the report wizard. In my form there is a button when clicked should fill the datatable mentioned above ( I checked if it is being filled by displaying its content in a dataGridView and by firing a messagebox that is triggered when 'datatable.rows.count > 0' ).

The reason that the datatable is initially empty is that it depends on some conditions that may alter the query used to fill it.

But finally when I load the form that has the report viewer it only has the names of the columns of the datatable and no contents. What's wrong ?

View 5 Replies View Related

C++ :: Looping User Input For Specific Data Type

Apr 17, 2015

Here's my code so far:

Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int dayNumber = 1;

[Code] ....

The code, when run, prompts the user to input an integer like this:

Code:

Day 1
Andy :>12
Bill :>7
Charlie :>15

Day 2
Andy :>5
Bill :>25
Charlie :>14
.
.
.
etc.

Ok, so the code prompts the user to enter an integer for each of the 3 persons and then increments the "Day" and so on... When the user enters a negative value (-1, -2, etc.), the loop is broken and the program ends. Alright, everything is hunky-dory so far. 2 things which I can't figure out.

1. when the user doesn't enter anything and just hits return, the cursor drops a line and is still awaiting an input but doesn't show the prompt "Andy :>", for example. How can I get it to repeat the last prompt when the user doesn't enter anything? Like:

Code:

Day 1
Andy :>
Andy :>
Andy :>12
Bill :>25
Charlie :>15
.
.
etc.

2. When the user enters a letter or a special character, the program blows up. How can I correct this?

I've tried changing the data type for the variable used for the input, tried using getline, get, etc. With my current beginner knowledge, I'm missing something. So how can I get this to work?

The program should allow only integers to be entered, while allowing a negative number to trigger the loop to break or the program to end, and while re-prompting the last person if the user entered an invalid input.

View 13 Replies View Related

C++ :: Traffic Control Program - Output Data At Specific Time

Oct 24, 2013

I was given an assignment to create a simple program for traffic control. How should i output data at a specific time, for e.g a driver approaches an intersection, the yellow light will flash indicating that he needs to slow down and then the red light to stop before taking a route. is there any function i can use to output red light a few seconds after yellow light.

View 10 Replies View Related

C++ :: How To Make Specific Character Show Up Specific Amount Of Times

Mar 5, 2013

How do I make a specific character show up a specific amount of times?

Like I am generating a random number then I need to make "|" show up that many times on the screen.

View 1 Replies View Related

C++ :: TXT File - How To Get Each Specific Value And Add Them All Together

Oct 10, 2013

so I wrote this code in class today and I'm almost done but I need to come up with some sort of equation to add up all the total values. The problem is I am reading data off a txt file so it's all being read as one thing. I don't know how to get each specific value and add them all together. This is my code so far.

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

[Code] .....

here's what's inside the input file

Chisel 50 9.99
Hammer 30 15.99
Nails 2000 0.99
Bolts 200 2.99
Nuts 300 1.99
Soap 55 1.89

I end up multiplying the amount by the price to get the total value as shown in the code above. Now I just don't know how to add the total value of each item to get the total overall value. Also I haven't used invTotal because I want that to be the overall total.

View 1 Replies View Related

C/C++ :: Getting Specific Info From A TXT File?

Oct 10, 2014

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?

View 5 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++ :: How To Read A Specific Word From A File

Aug 12, 2014

How would one go about doing this? I am very fond with Windows I/O, but not so much with this subject. I am decent with fstream, probably not as skilled at it as I should be, but I assume <fstream> would be a better choice, since it isn't locked to Windows.

Anyway, say I have a .txt file like this:

Bill is a cow.
Bill likes meat.
Bob is a pig.
Bob and Bill are friends.

And I want to count the number of times "Bill" is written. How would I do that?

View 5 Replies View Related

C/C++ :: How To Read Specific Column From A File

Nov 21, 2013

I have a .txt file which contains 121 lines,now I want to read the no 20 columns from that file. How to read it. I have tried the following code.

my c.txt file look like following :

A B C D E.....AAA
 
#include<stdio.h>
#include "conio.h"
#include "string.h"    
int main() {
    FILE *fp;  
    char a2[500];

[Code] ....

View 1 Replies View Related

C :: How To Input Lines At A Specific Area In File

Feb 15, 2013

how can i input lines at a specific area in my file. please provide code

View 3 Replies View Related

C/C++ :: How To Open Text File From A Specific Location

Feb 2, 2014

I'm having trouble opening a file from a specific location.

#include "maidcafe.h"
....
char directory[80] = {"C:UsersPublicDocumentsAnime NotesTransaction"};
char code[20];
printf("Enter file name");
gets(code);
strcat(directory,code);
system("start "" %s",directory);    

i thought this would work, but it didn't xD. I got an error

View 3 Replies View Related

C :: File Operations - Fwrite Padding Extra Data In File Compare To Data Provided As Input

Oct 28, 2014

I am trying to write my files to another subfolder . Below is my program.

Code:
cat th6.c
#include <pthread.h>
#include <stdio.h>
#include <string.h>

#define SIZE 8
#define NUMELM 8

[Code] ....

I observe my filename along with directory as text in the new file created in sublfolder. This is output.

[cporgs/apue/threads]: mkdir first
[cporgs/apue/threads]: ./a.out test.txt first
test.txt -- first/test.txt
dfdfdfdfdfdfdf-14
dfdfdfdfdfdfdf-14
in thread test.txt first
[cporgs/apue/threads]: cat first/test.txt
dfdfdfdfdfdfdffirst/test.txt
[cporgs/apue/threads]: cat test.txt
dfdfdfdfdfdfdf

I could not able to get from where this filename and folder is getting added.

View 4 Replies View Related

C :: Read Specific Values From A File And Store Them In Arrays

Apr 14, 2013

What i try to do is to write a code which reads some specific values from a file and stores them in an array. My File looks like this

Code:

XFOIL Version 6.96
Calculated polar for: Myfoil
1 1 Reynolds number fixed Mach number fixed
xtrf = 1.000 (top) 1.000 (bottom)
Mach = 0.000 Re = 0.200 e 6 Ncrit = 4.000
}

[code]...

View 11 Replies View Related

C# :: StreamReader And StreamWriter - Overwriting Specific Line In A File?

Apr 10, 2014

I am currently working on a small project, which is an ATM simulator but, lately, I've been stuck in a part where I have to overwrite a specific line in a .dat file to update the account's checking and savings balance, once the transaction has been done. I have to use StreamReader and StreamWriter to complete the task and I have also being told to try Collections... which I'm not sure as to why.

Here's my code so far:

private void btnOKd_Click(object sender, EventArgs e) {
int transaction = 0;
atmTIMER.Elapsed += new ElapsedEventHandler(timerRESTART);
FileStream fileTRANSACTIONS = new FileStream("C:\Users\Voyage\Desktop\ATMSim\ATMsim\Transactions.dat", FileMode.Open);

[Code] .....

View 14 Replies View Related







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