I was never able to get transcendals example to work. I need to open a file in binary and I have no clue on where to start...does someone have an example they can show me? Is there a way to open somewhere around 30 characters at a time? :confused:
Printable View
I was never able to get transcendals example to work. I need to open a file in binary and I have no clue on where to start...does someone have an example they can show me? Is there a way to open somewhere around 30 characters at a time? :confused:
C:
FILE* f = fopen("filename", "rb");
char buf[30];
while(fread(buf, 30, 1, f))
{
...
}
well don't I feel stupid... :p pondering on how to do this and it ends up being only a few lines.
You're on a C++ rampage today cornedbee! :eek: Thanks for all your help! :D
I get output like this
<+<-<+<¦¦HPB+<¤='=Æ=Ö=á=_=-=+=2>;>K>T>d>x>¦¦HPB~>Å>¼>_>_
?µ?_?_?·?_?½2+2_2_2$3L3¢3á3_3_3E4N4S4[4a4¦¦HPBg4o4u4{4â4
B+6¶6²6 7%7W7í7ª7+7¶728>8ÿ8ñ89¦¦HPB9%9-939<9D9L9R9[9a9
ô:_:¦:¦:µ:_:_:;;#;¦¦HPB+;-;+;<<#<Y<e<+<¦<_<_<*=0=T=¦
à>«>+>->µ>?¦¦HPB?152ü2-2+2_2¦¦HPB33)3.3Q3V3y3~3ª34
¦5¦5+5+5_56¶6t6î7¦¦HPB'7.7+7§8!8@8E8o8¡8B9l9x9¦9+9e:¦¦H
=9=>=+=¦¦HPB_=0>]>¦>+>->@?\?å?«?&1x1Æ1_122_2è2¦2¶2_2_23
4D4P4X4f4l4x4ƒ4_4¦¦HPB+4_4_4²45§55S5Z5Ç5ä5ê5î5É5+5¦¦HPB
+7_7%838L8Z8«8+8-8_899$9E9M9e9x9¦¦HPB+9_9_9_9_9°9n9%:K
-:+:_:_:_:J;U;p;w;|;Ç;ä;¦¦HPBí;-;²;<<<¶<<< <j<p<t<x
6=@=J=g=p={=¦¦HPB33$3/383N3X3^3j3q3w33ç3ô3£3¦¦HPB½3¦3+
5¦¦HPB,5r5°89959;9C9P9X9_9x9~9ç9î9¦¦HPBò9º9«9+9_9·9 :(
2-2+2_2_2¦¦HPB_2_2-3¬4p:y:t;};+;-;K<Z<G=s=£=_=_=¦¦HPB>¿
9$9(9,90949¦¦HPB89M9Q9U9Y9]9É9ö9ÿ9£9á9ñ9¿9¼9_9¦¦HPB¦9+9+
==a=¦¦HPB¡=¦=%>¦>+>M?T?c?-?-?S2]2n2{2à2_2-2¦2_23Æ3+34è
+5¦5_5_56'6:6¦¦HPBa6_67h7Ç7ç7Å7ö7ÿ7£7+7_7888¦¦HPB¶8
99¦¦HPB9 9$9A9k9¥9ñ9¿9¼9_9¦9+9+9+9
:¦¦HPB:¶:::{:É:ó:¼:+:_:_:5;O;n;â;¦¦HPBò;ƒ;_;
<_<_<=I=S=o=è=ù=+=_=_=¦¦HPB>'>C>L>Y>_>???+?4?B?K?Y?
0u0ì0+0+0+0_1-191?1U1s11+1¦¦HPB¦1_1282]2b2j22+2_2_23
3_3n3¤4 4*4H4]4|4¦¦HPBç4æ4_4²4?5I5~5¦5+5-5_56%6¢7_7¦¦HP
9-9+9·9¦¦HPB¤:!:+:ü:ö:¦:_:÷:t;z;Ç;å;î;Æ;ÿ;¦¦HPBP;ñ;¬;_;¦
is that supposed to happen? :eek:
:rolleyes:
so am I supposed to get output like that? :confused:
Well, if you try and print the buffer you'll have problems because in a binary file, you may or may not have embedded NULLs in there. The only real way is to loop through it, printing a character at a time.
What most things will do if you try and print a character buffer is to go through until they hit NULL (which is reasonable enough, really).