cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Ascii code to Binary code
Ascii code to Binary code
Jun 24, 2014 at 2:01pm UTC
Tita
(8)
Hi!
Someone would have a idea how to transform a Text file to a Binary file. For example, I want to converse "42000" in binary, in my binary file.
In first, i tride with function "atoi", but, that give me a strange value.
After, I tried with this instruction:
while(fgets(ligne,100,FileText))
fwrite(ligne,1,sizeof(ligne),FileBin);
But it doen't change the format of the the "42000", when I visualize the Binary File.
Jun 24, 2014 at 4:01pm UTC
MiiNiPaa
(8886)
Line "42000" as string will be exactly six bytes with values 52, 50, 48, 48, 48, 0.
Any text editor will show these bytes as 42000.
ASCII string value and it binary representation are the same. That is why you do not see any difference.
Topic archived. No new replies allowed.