C/C++ :: Overwrite One Specific Sector In HDD

Apr 26, 2015

I want to replace what is in a specific sector with value inside a buffer(dummy value). This code will read what is inside a specific sector. To make sure it works it display what is inside the sector and it displays the chosen dummy value. (the two cout's in main)

What I want to do is to replace the dummy value with what is inside the specific sector. So if the dummy value is '0', I want to replace what is in sector 285 with '0'.

#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
using namespace std;
#define FILE_SHARE_VALID_FLAGS 0x00000007
#define BUFFER_SIZE 512

[Code] ....

View 1 Replies


ADVERTISEMENT

C/C++ :: Writing To Specific Sector In Flash Drive

Apr 22, 2015

I am trying to write a to a specific sector in a flash drive. The problem is that it will only allow me to write to sectors 0 to 15. When I try sector 16 or higher nothing happens, but in sector 0 to 15 is is working fine.

#define BUFFER_SIZE 512
int main(void) {
FILE *volume;
int k = 0;
long long sector = 0;
char buf[BUFFER_SIZE] = {0};

[Code] .....

View 14 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++ :: Add And Overwrite Class Methods Through Lua

Oct 9, 2013

I'm using lua 5.2.2 with luabind 0.9.

I'd like to be able to add additional class-methods through lua for any classes that I've bound in c++, but I'm unsure how to do it.

The problem is that luabind uses a function as the __index-metamethod for any bound classes instead of a table, so I don't see a way to access the class-methods at all.

e.g., I'm binding my classes like this:

luabind::module(lua) [
luabind::class_<testClass>("TestClass")
.def(luabind::constructor<>())
.def("TestFunc",&TestFunc)
];

What I essentially want to do is to add a lua-function to the list of methods for this class, and be able to overwrite existing ones:

local t = tableOfClassMethods
local r = t.TestFunc -- Reference to the c++-function we've bound
t.SomeFunction = function(o) end -- New function for all objects of this class
t.TestFunc = function(o) end -- Should overwrite the c++-function of the same name

View 2 Replies View Related

C++ :: How To Overwrite Text In File

Jan 25, 2013

I have a question about controlling a file.With MFC, I can overwrite stream with code blew.

f.Open(strFullPath, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite | CFile::typeBinary, &ex)
f.write(buffer, buffersize);

For instance, file called "A.txt" has "ABCDE" in it. Then it will be "KKCDE" when I put the text "KK" like this.

char buffer[2] = {'K','K'};
f.write(buffer, buffersize);

I want to make it out in C/C++ not in MFC.So, I did like this.

FILE *f;

f = fopen(path, "a");
// I put "a" as a mode, and other modes don't work neither.
fseek(f,0,SEEK_SET);
fwrite(buffer, 1, buffersize, f);

the result is "ABCDEDD" not "KKCDE".(with "a" mode which means "append")
(with "w" mode, it will be "KK"(re-created))

I need to know how to overwrite text in file.

View 2 Replies View Related

C :: How To Access Sata Hard Drive At Sector Level

Mar 7, 2013

I want to access sata hard drive(eg. D drive) at sector level using C programming.I want to read the values stored in the memory locations.

View 3 Replies View Related

C# :: Overwrite Text In Masked Textbox Without Selecting Or Deleting Content?

Aug 23, 2012

I was wondering if there is a -> simple <- way to overwrite existing text in a masked texbox...

Example: I have a masked textbox, where you can insert dates. That means that you can enter only numbers for the day, month and year.

If I have to do it programmatically, there is no problem... I already have some ideas how I could do something like that, but I would like to know if VS has any parameter or any option I only have to activate.

View 6 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++ :: Returning A Specific Value?

Jun 8, 2014

How do I return a specific value from a function in order for me to cout it in my int main?

In this case i have solved for a value sigma1 in my function but i want to use the value of sigma1 in my int main also and in other places so how would i do that?

#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdlib>

[Code].....

View 5 Replies View Related

C# :: How To Get AI To Look For Specific Buttons

May 5, 2014

Basically I am creating a game and I need the ai to look for specific buttons. At the moment this is the code I have, and what it does is it makes the ai look for any random button that has't already been clicked.

Code:

private Button look_for_spaces() {
Console.WriteLine("Looking for spaces");
Button b = null;
foreach (Control c in Controls) {
b = c as Button; // performs a cast

[Code] .....

Now what I'm trying to do is make the ai go through 4 searches in steps instead of looking for any button. I want it first to look for buttons 1, 2 and 3, if there's a space in any then it will be clicked but if all of them are already clicked it will look for spaces in buttons 4, 5 and 6 and so on if that makes sense. But i'm not too sure how I would do it.

View 3 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++ ::  Going To A Specific Line Through Ifstream

Jan 12, 2015

I want to access specific lines in a "*.txt" file. I've heard of seekp() and what not, but don't know how to call them as such.

View 6 Replies View Related

C/C++ :: How To Find A Specific Value In Array

Mar 16, 2015

im having trouble with a function im writing. Its supposed to find the minimum value in an array and return the location of that value heres what i have so far :

int findLowest (int numb []) {
// findLow will hold the subscript of the lowest value in the array
int findLow = numb[0];
int x;
for (x = 0; x < 5; x++){
if (numb[x] < findLow)
findLow = x;
}
return findLow;
}

View 3 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# :: How To Get A Specific List Element

Nov 26, 2014

Here's my list code:

Color.FromArgb(alfa, 0, 255, 255),
Color.FromArgb(alfa, 0, 255, 0),
Color.FromArgb(alfa, 64, 255, 0),
Color.FromArgb(alfa, 128, 255, 0),
Color.FromArgb(alfa, 192, 255, 0),
Color.FromArgb(alfa, 255, 255, 0),
Color.FromArgb(alfa, 255, 192, 0),
Color.FromArgb(alfa, 255, 128, 0),
Color.FromArgb(alfa, 255, 64, 0),
Color.FromArgb(alfa, 255, 0, 0)

How can I get a specific element value from that list?

For example:

if(true)
{
//get "192" from Color.FromArgb(alfa, 255, 192, 0)
}

I don't see the "Edit" option and I've noticed a slight error in the previous post.There should be, obviously, [code]if(true)

{
//get "192" from Color.FromArgb(alfa, 255, 192, 0)
}

I was missing the closing tag.

View 2 Replies View Related

C++ :: How To Display Item At Specific Tab Position

Nov 23, 2013

I used VB6 before to output file.

I set my output to file to tab(20) or tab(45) respectively.

In C++, how do I do this?

View 4 Replies View Related

C++ :: Saving Specific Bits From 64-bit Number

Jun 24, 2013

I have a 64-bit uint64_t number:

Code:
Primitive<uint64_t> b = 0xCCCCCCCC00000000; I need to save the first 31 (most important) bits - 7FFFFFFE.

I found this solution in the Internet:

Code:
start = (((b)>>(first)) & ((1<<(((last+1)-(first))))-1)); but in my case for this code:
Code: Primitive<uint64_t> start = (((b)>>(32)) & ((1<<(((63+1)-(32))))-1));

I get an error: left shift count >= width of type

And even if I change 63 to 62:

Code:
Primitive<uint64_t> start = (((b)>>(32)) & ((1<<(((62+1)-(32))))-1));

I get: error: integer overflow in expression

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 :: 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 :: Calculator - Input Specific Number?

Feb 11, 2013

In my calculator, I am trying to make it so that you put enter 1 to add, 2 to subtract, 3 to multiply, and 4 to divide. I am facing the issue of making it so that you must enter a number, however instead of it being any number, it must be 1, 2, 3, or 4, and if it is not any of those numbers, you must re-enter the number. Here is a little snippet of my code:

Code:

printf("Please enter 1 to add, 2 to subtract, 3 to multiply, or 4 to multiply: ");
while (scanf("%d", &input) != 1) {
while (getchar() != '
');
printf("Invalid option. Please try again: ");

[Code] ....

how I can make the loop affect specific numbers.

View 4 Replies View Related

C++ :: Program To Calculate How Many X Or / And Y From Specific Range

Nov 7, 2013

X and Y are numbers

For example: how many 2 or/and 5 are inside range of 0 to 30.
for or: there are 8 (2,5,12,15,22,25)
for and: there is only one (25).

View 1 Replies View Related

C++ :: Building A Matrix With Specific Dimension

Jan 23, 2015

I would like to initialize a N-dimensional matrix by specifying the dimension N.

To be clearer :

if N=2 I use to do that :
std::vector<std::vector<double>> myMatrix;
if N=3 :
std::vector<std::vector<std::vector<double>>> myMatrix;
and so on...

What I would like is to give N as an argument of a function which construct a N-dimensional empty matrix. Is that possible ?

View 2 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++ :: Copying A Buffer From A Specific Location

Jan 20, 2015

I already wrote:
strncpy(buff2, buff1[i], strlen(buff1)-i );

but this function seem to just copy from the beginning of a buffer to another, not from the ith element.Is there such a function?

Buff1&buff2 are char[10000] and i is declared int, holding the interesting element's position.

View 4 Replies View Related

C++ :: How To Access A Specific Member If Keys Are Same

May 19, 2013

I understand what a map is and all, but what purpose does multimap serve?How can you access a specific member if the keys are the same?

View 8 Replies View Related







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