|
-
Dec 22nd, 2001, 03:21 PM
#1
Thread Starter
Frenzied Member
files.....
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?
-
Dec 22nd, 2001, 03:23 PM
#2
C:
FILE* f = fopen("filename", "rb");
char buf[30];
while(fread(buf, 30, 1, f))
{
...
}
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 22nd, 2001, 03:25 PM
#3
Thread Starter
Frenzied Member
-
Dec 22nd, 2001, 03:27 PM
#4
Thread Starter
Frenzied Member
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?
-
Dec 22nd, 2001, 10:14 PM
#5
Thread Starter
Frenzied Member
so am I supposed to get output like that?
-
Dec 23rd, 2001, 05:59 AM
#6
Monday Morning Lunatic
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).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|