bitset<16> v8 and its value is something like "1100110111001101
, как мне преобразовать его в const char, чтобы я мог записать его в файл, используя fprintf (stream, c);
bitset<16> di0;
di0[2] = 1;
unsigned long i = di0.to_ulong();
const char c = static_cast<const char>(i); // simplest -- no checks for 8 bit bitsets
cout << di0 << endl;
//di0 = 0;
cout << di0 << endl;
char line[100];
errno_t err;
// Open for read (will fail if file "crt_fopen_s.c" does not exist)
err = fopen_s(&stream, "outfile.c", "r");
if (err == 0)
{
printf("The file 'outfile.c' was opened\n");
}
else
{
printf("The file 'outfile.c' was not opened\n");
}
// Open output file for writing. Using _fsopen allows us to
// убедитесь, что никто не пишет в файл, пока мы // пишем в него.// if ((stream = _fsopen ("outfile", "wt", _SH_DENYWR))! = NULL) {fprintf (stream, "никто другой в сети не может писать" "в этот файл, пока мы не закончим. \ n");
fprintf(stream, c);
printf("%s", line);
//cout << "%s" << endl;
fclose(stream);