0

hi.
How to save a bit on the physical disk in the C + +.
ofstream write only file, and I would like to save the hard bits but I do not know how to do it

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by pala2222
0

You're still writing bits, even if you write a file.

Also, you can't just change one bit of a disk. The minimum addressable amount is typically 512 bytes (at the disk level).

The file system usually aggregates these into single units called clusters - who's size can be anything from 4K to 64K.

Now what are you really trying to do here?

0

how to write in C + + to save these bits on the disk because I do not know

I wrote such a thing but nothing happens

#include <windows.h>

int main()
{
    WCHAR disc_name[6];
    mbstowcs(disc_name, "\\.\D:", 6); nadpisac
    HANDLE h = CreateFile(disc_name, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
    char data[512]; //bufor,
    memset(data, 1, 512);
    unsigned long count;
    WriteFile(h, data, 512, &count, NULL); 
}

Edited by Nick Evan: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.