C++ :: Reading And Editing A File Bit By Bit
Dec 7, 2013
Basically what I am looking for is a way to get a block memory, copy it into ram in a format along the line of bit[#], replace the original with a new code that may or may not be the same size(they will be something to ensure does not try to save a fraction of a byte).
Is there an easy way to do this or do I just need to read work from a bin file?
View 3 Replies
ADVERTISEMENT
Feb 25, 2014
I am trying to write a program that will read the id3v1 tag of an mp3 file, output the current information, and then allow the user to edit the ID3 tag. I can get it to output the information but I'm having some issues getting it to edit correctly. It seems to try to edit the wrong fields.
#include <iostream>
#include <fstream>
using namespace std;
int main(){
int end;
ifstream myInputFile;
myInputFile.open("01-Cheeseburger in Paradise.mp3", ios::in);
[Code] ....
View 8 Replies
View Related
Jan 2, 2014
I have a problem editing a text file in c
Code:
#include <stdio.h>#include <stdlib.h>
#include <string.h>
typedef struct
{
char *name;
float gpa;
[Code] ....
View 3 Replies
View Related
Apr 16, 2013
Well,i hav a question requiring me to edit sales achieved by an employee for a particular month.
I'm having a dat.file which following format
Employee ID
Name
Sales(for a year)
For example
A00001
Harlem Shake
10.00 20.00 30.00 40.00 50.00 60.00 70.00 80.00 90.00 100.00 110.00 120.00
Wad I wanna is TO EDIT only the sales for July which is 70.00 to a new amount with other months remain intact.
I need to search particular id which will then link to their respective sales.
ofstream outFile;
string empID;
cout<<"Please Enter Employee ID:
[Code] ....
I tried to run myself before.But I could only create a new line instead of replacing.
To my understanding with ios::app ..will use the same file for editing..
View 4 Replies
View Related
Oct 30, 2014
I have a button that opens a file dialog box so that a user can pick a file. I only need it for the path and file name to be passed to another program. I do not want to open the file or care about its contents. I just want the name and path.
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
[Code].....
The problem is that as long as the program is running the file that the user picked is locked for editing. Adding the Dispose() had no affect. Multiselect and ReadOnlyChecked have no affect. Only closing the application frees the file.
View 7 Replies
View Related
Oct 19, 2014
I have a .dll file that is used by some kind of launcher. Now the .dll file has some kind of timer on it and after that set of time it wont let me use it, how i can edit that out of a .dll?
View 4 Replies
View Related
May 19, 2012
i have this program that i am undertaking.....this project needs to store customer details, edit them and delete them...now i am facing the problem of deriving a code to edit those details...
MY CODE
HTML Code:
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main () {
int choice [1];
string name;
[code].....
View 4 Replies
View Related
Nov 14, 2014
You are requested to create an inventory control application for a drink stall (give a name to the stall). The application is used to show the list of drinks the stall sells, how many of each item on‐hand and the cost of each item. The records are to be saved and retrieved to/from a binary file called “drinks.txt”. For each drink in the stall, your program is to keep the information as a Record Structure called DrinkRecord. The structure should at least consist of the following:
(1) Item Number
(2) Item Name
(3) Quantity
(4) Unit Price
Your application should have the following features:
(a) Display a drink information
(b) Add a new drink information
(c) Update a new drink information
(d) Delete a drink information
(e) Display all drink information
#include <string>
#include <fstream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
[code].....
Everything works fine with minor issues, but I'm having trouble with the editing function. I need to be able to search for a specific drink then be able to edit its contents and print the new contents to the file. I have not created a structure yet. I will do that as soon as possible.
View 1 Replies
View Related
Mar 10, 2014
I'm trying to edit an image by multiplying the red component of each pixel by 10 and leaving the other components (green and blue) untouched. I'm not really sure how I'm supposed to edit the pixels one by one. I have this so far. I think there is something wrong with my ppm header as well. Is there a way to make a ppm header without specifying the bounds so that it conforms to the image you are putting in?
Code:
#include <stdlib.h>
#include <stdio.h>
#define PICTURE_FILE 1
#define MIN_ARGS 2
#define h 768
#define w 1024
void solve(FILE *in_picture, FILE *out_picture)
[Code] .....
View 6 Replies
View Related
Sep 11, 2014
I have this function that takes the collision location from an object then creates a new object for particle effects.
This is one of the functions that is called when creating the particle,void Particles_Create(i32 iID, Vec3 &vecPos, i32 ProjectileType, i32 iNumberOfParticles, float fSpread, float fGrowSpeed, float fMaxSpeed, float fMaxSize, float fParticleTime);
I want to be able to change the "Vec3 &vecPos" variable, when I define the variable that goes into the function I've defined it as: "Vec3 vecPos;" if I define it as "Vec3 vecPos(float fvx,float fvy,float fvz);" the variable cant be fed into the function.
I cant change my function because its used elsewhere but I want to be able to change the x,y and z elements inside the Vec3 vecPos variable. How without redefining it as Vec3 vecPos(float fvx,float fvy,float fvz);
View 10 Replies
View Related
Sep 6, 2014
I have tried googling, so, reddit, irc, and various other forums. Anyways, I am writing a todo list app in c. It generates an xml tree that looks something like this: [URL]... . The problem where I am struggling, is in the function todo_complete, I try to make the attribute of an item switch from false to true. it does it without error, but I can't make it stay that way. here is the code: [URL]...
View 3 Replies
View Related
Mar 4, 2014
I have a char correctAns[100] which is empty when initialized. i want to make it hold a different string for each section, so i can use strcmp to compare the correctAns to the answer given by user. here is code
#include <stdio.h>
#include <string.h>
int main() {
char answer[100];
int checkAns;
char correctAns[100] , incorrectAns[100];
[Code] .....
View 1 Replies
View Related
Dec 6, 2014
I'm trying to create a program for my wife to be able to browser through and edit folders and specifically word documents- really just a shiny organization tool without having to open up Word. I'll be integrating other functions into this program but Word is what I'm worried about.
At the moment I've been able to create a file browser with the ability to add and remove files within the main directory of the program. Basically just C:Users\%user%mainDirdata*
Within the data folder I have the main folders which will be displayed as tabs across the top and then any subfolders of the main folders will be displayed on the left side after you click on the main tab.
[URL]
I'd need the toolbars to be integrated into the program across the top and then a window that changes depending on the document selected on the left side based on the content of the word document located in that folder. I haven't been able to find anything online and I'm not really able to spend $800 on the alternates that look like they just do automation as well.
View 10 Replies
View Related
Jul 10, 2013
Basically I have an tile class with the following variables: x, y, texture, and solid. I have created an array called tile MAP[map_tiles_x][map_tiles_y]. The object of the following snip-it of code is to loop through all of the tiles in the map placing their default values in each. For some reason this code does not work as planned, but in theory shouldn't it? I cannot see why it doesn't work. (BTW I do plan on open sourcing this map editor.
void init_map(){
for (int tile_y; tile_y < map_tiles_y; tile_y++){
for (int tile_x; tile_x < map_tiles_x; tile_x++){
MAP[tile_x][tile_y].x = tile_x * tile_size;
MAP[tile_x][tile_y].y = tile_y * tile_size;
MAP[tile_x][tile_y].solid = false;
std::cout << MAP[tile_x][tile_y].x << ", " << MAP[tile_x][tile_y].y;
} }
I should also add the effect of the code. Basically it only sets the default coordinates for the first object :/.
View 4 Replies
View Related
Sep 30, 2014
I'm using windows forms and I have a parent dialog box that consists of a text box and a drop-down that launches a child dialog box. The child takes user input and then prints dialog to the text box in the parent. However, the output does not appear in the text box until I close the child.
Now my question is, how do I get the text to appear without closing the child? I hit a button to send the info to the text box, but it still doesn't appear until the child closes. I also need to set up a button to suspend the child so that the user can click/copy/etc the parent.
View 7 Replies
View Related
Nov 26, 2013
Program background: Ticket Sales Details You will sell tickets in advance and at the door. Prices for buying in advance and at the door will be given. Also, the total number of tickets sold in advance will be given. Each guest will have a unique number. If there are n tickets sold in advance, then these guests will be numbered 0 through n-1. As the event starts, requests to buy tickets at the door may be made and these guests will be numbered sequentially, starting at the lowest unassigned number. The maximum number of guests will be 1000. The first line of the file contains the following three values, separated by spaces: Cost of the presales tickets (in dollars), Cost of the tickets at the door (in dollars), and the number of presale tickets. The first two values will be positive real numbers to two decimal places and the last will be a positive integer.
The second line of the file will contain one positive integer representing the number of auction items followed by a positive real value to two decimal places (at most) representing the minimum bid increment, in dollars. The first value is guaranteed to be 1000 or less and the second will be in between 1 and 50, inclusive.
The third line of the file will contain all the prices of the auction items, in dollars, separated by spaces, in order. Thus, the first price is the price of item 0, the next price is the price of item 1, and so on. These values will be real numbers represented to up to 2 decimal places.
The fourth line of the file will contain the three following positive integers pertaining to the raffle: the number of raffle tickets available, the cost of a raffle ticket in dollars, and the number of raffle prizes. (It's strange to have raffle tickets that don't cost a whole number of dollars.)
The fifth line of the file will contain each of the values of the raffle items, in dollars, separated by spaces, in order. Thus, the first price is the price if item 0, the next price is the price of item 1, and so on. These values will be real numbers with upto 2 decimal places.
The sixth line of the file will contain ten positive integers representing the number of each of the drinks 0 through 9, in order, that are in stock.
The seventh line of the file will contain ten positive real numbers with upto 2 decimal places representing the price of each of the drinks 0 through 9, in order.
The eighth line of the file will contain a single positive integer, numEvents, representing the number of events that occur at the charity ball. These events are split into two groups: actions by guests at the ball and awards given (raffle, auction, person, totalrevenue). All of the actions precede all of the awards. You will produce exactly one line of output for each event described. Here are the formats of each event that could occur:
If a patron buys a ticket at the door, a command will be on a line by itself:
BUY TICKET k
where k is a positive integer indicating the number of tickets bought at the door. These guests will be numbered as previously mentioned. You are guaranteed that the total number of tickets bought, including presales, will not exceed 1000. This is what I have so far and I cannot figure out why it wont calculate the total revenue. I am not completely sure if it is even accessing the if statement in main.
Code:
#include <stdio.h> #include <stdlib.h>
#include <string.h>
#define N 1000
[Code].....
View 4 Replies
View Related
Nov 7, 2014
I am reading a file then printing the data onto the other file. It is working, however when I check to see if each variable is being properly set after reading the file a issue arises.
Example of the file being read
Code:
Vehicle PV50CAN passed camera 1 at 05:33:26.
Vehicle W867BRO passed camera 1 at 05:33:29.
Vehicle KQ63ARU passed camera 1 at 05:33:38.
Vehicle K954ITQ passed camera 1 at 05:33:40.
Vehicle V220MXB passed camera 1 at 05:33:42.
[Code] .....
View 14 Replies
View Related
Jan 28, 2014
I am trying to write a program that will open a file with 2 points, take those points, determine what quadrant those points are in, and save the result back into the same file without truncating the data.
I'm having some trouble with my file I/O. I can't get my program to read the two values for X and Y that I put in the points.txt file. It simply uses whatever random number was used last time in that block of memory. In my points.txt file I put something like "4 -5" and it wont assign those numbers to my X and Y variables. I believe the issue is on line 25
#include <iostream>
#include <fstream>
using namespace std ;
int main() {
//defining X and Y
double X, Y ;
[Code] ....
View 14 Replies
View Related
Jan 5, 2014
If I am reading data from a .txt file with a person's last name and first name (e.g. Miller Andrew), How do I output the same data with the first name followed by the last ?(e.g. Andrew Miller) Do I use the ignore function?
View 2 Replies
View Related
Aug 30, 2014
I want to know how to read a .pgm file from my hdd and store it in a 2d array so i can perform some action on the array later on. This is ny first time working with an imqge in c so i know nothing about it. .
View 3 Replies
View Related
May 25, 2014
I have been given a task to make a c++ program that promptsd the user to enter a mp3 file name, read the ID3v1.1 tag and displays it. It then should prompt the user to to decide if they want to edit the comments section of it, then if they edit the section, it should re-print the updated ID3 tag. The list of genres are in a cstring that is as follows.
char genre[126][128] =
{
"Blues" "Classic Rock", "Country", "Dance", "Disco", "Funk",
"Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other",
"Pop", "R&B", "Rap", "Raggae", "Rock", "Techno", "Industrial",
"Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack",
[Code] .....
View 1 Replies
View Related
Aug 22, 2012
Using the feof() function in the output file i have the last value twice.
This is the input:
1 3 6
1 1 4
0 3 1
1 1 6
0 6 2
1 1 6
And the output should be:
12
6
15
13
But using the feof() the last value appears twice:
12
6
15
13
13
How can i change that?
while(!feof(pfile1)) {
sum=0;
fscanf(pfile1,"%d%d%d",&choice,&day,&val);
if(choice==0)
[Code] ....
View 1 Replies
View Related
Dec 9, 2014
How to read a grayscale jpeg image in C++ ?
How do I write the code to read the jpeg file and store its content in a 2D array
View 1 Replies
View Related
Mar 29, 2014
I am practicing with C++ since I done most of C already and I have a problem with reading spaces from a .txt file.
I created a little program that creates a wannabe Cube in wannabe 3D xd, well to appear as 3D like:
Code:
cout << " O------O" << endl;
cout << " / /|" << endl;
cout << " / / |" << endl;
cout << " / / |" << endl;
[Code] .....
The actual code is a bit longer since it offers you to input the size and then it draws the pic. Now that wasn't so hard and I've done that but now I wanted to implement the "MessageBox" func for output.
I managed to write the cube in file cube.txt but when I'm reading from it 1 char at a time since I need to output as char array it avoids all spaces and new lines and just puts all symbols in the same row.
I didn't have that issue with C and I've found on stackoverlow a solution using strings & getline but I need it to be in "char" form.
How to actually read spaces and newlines? This is my current code for reading from file:
Code:
ifstream di("kocka.txt", ios_base::in);
char c[5000];
int br=0;
while( di >> c[br])
{
br++;
}
MessageBox(NULL, c, "Kocka", MB_ICONHAND);
di.close(); P.S kocka = cube (in croatian )
View 1 Replies
View Related
Nov 3, 2014
I'm writing a program using Huffman algorithm to compress text file. I have tested my program by just printing the printing ASCII character to file and it worked fine. However, now I have to implement using bits and my program doesn't work. It seems like I'm not reading or writing the right bits. Here is the result of my testing:In the input file I put abc the input file to compress it. Then I uncompress it the out out is aaa. Below is a snippet of how I read and write bits
Code:
class BitInput {
istream& in; // the istream to delegate to
char buf; // the buffer of bits
int nbits; public:
BitInputStream(istream& s) : in(s), buf(0), bufi(8) { }
[Code] ....
View 4 Replies
View Related
Dec 10, 2013
Basically I want to open a binary file containing utf-8 encoded characers. The length of the encoding is variable: 1, 2 or 3 bytes.
Rules are:
if the read byte has 0 as strong bit then it represents a single byte.
if the read byte has 11 as strong bits then it represents the first byte of a 2 or 3 length character.
if the read byte has 10 as strong bits then it represents the second or third byte of a 2 or 3 length character.
Each character encoded on 2 or 3 byte has to start with a 11xxxxxx and following bytes has to start with 10xxxxxx
So i need to go through his file, read byte per byte to analyse what kind of byte it is, sometimes go back to previous character etc etc
My goal is to identify all encoded characters in the file and then process them by convering them to Unicode value, storage in array etc...
View 4 Replies
View Related