Inserting hex characters in the output
Hey,
I want to insert a character 0x0a after a string in my output to file. To look something like this:
I tried inserting a newline, that's what 0a is, but it write two bites instead of one. I asigned '\n' to an unsigned char and then print it, it doesn't work.
The source:
Code:
#include<iostream>
#include <cstdio>
using namespace std;
int
main (void)
{
char str1[] = "one", str2[] = "two";
char c = 0xa;
FILE *out;
out = fopen("h:/c/HexTest.txt", "w");
fprintf(out, "%s%c%s%c", str1, c, str2, c);
return 0;
}
here's the current output, in ASCII:
Hex: 6F 6E 65 0D 0A 74 77 6F 0D 0A.
I only want the 0A , without 0D.
Is that doable?
thanks.