Skip to main content
user13479's user avatar
user13479's user avatar
user13479's user avatar
user13479
  • Member for 8 years, 3 months
  • Last seen more than 8 years ago
awarded
comment
pset6 problem loading jpg file
I guess there is still so much to lean... May I ask why does the program typedef char BYTE at the beginning, if the program can still work with char* buffer or char* content? What is the point of typedef char BYTE ??
accepted
comment
pset6 problem loading jpg file
I mean, even using fread, it gets datas like 0x00, which is a number in 8-bits. When storing it into char* buffer, is it not cast into char??? Also, I just noticed that in interpret(), it write char* content; while in transfer(), it writes BYTE* content. Why the difference?
accepted
comment
pset6 problem loading jpg file
I made it! all check50 passed! I still have some questions though: (1) I wrote fgetc version and fread version, both works with both BYTE* buffer and char* buffer. However, I want to know which is the correct way to code? (2) Whether I put BYTE* buffer or char* buffer it's still an array of "char" type data. After fgetc() or fread() reads the first by of jpg file 0xff, which is 255 and about to to store it to buffer, how come the "8-bit number is not cast to a char and therefore causing problems?
awarded
revised
pset6 problem loading jpg file
added 11 characters in body
Loading…
comment
pset6 server trapped in if (connected())
I think I kinda get why char* buffer will get in trouble with image files. But content is already defined as "BYTE** content", * content must take BYTE* which is char*. I can not change it. How can I fix this problem?
revised
pset6 problem loading jpg file
added 1 character in body
Loading…
revised
pset6 problem loading jpg file
added 362 characters in body
Loading…
revised
pset6 problem loading jpg file
added 33 characters in body
Loading…
revised
pset6 problem loading jpg file
deleted 67 characters in body
Loading…
asked
Loading…
revised
pset6 server trapped in if (connected())
deleted 3730 characters in body
Loading…
comment
pset6 server trapped in if (connected())
I changed the way using *content and I rewrite *length = counter + 1; to stop from treating content as a string. However it still does not work. And I could not figure out how to simplify by putting just BYTE buffer, since fread requires an address to write in, it can't be a char. I definitely need more advices....I updated the code.
revised
pset6 server trapped in if (connected())
deleted 247 characters in body
Loading…
awarded
comment
pset6 server trapped in if (connected())
Sorry I dont think I understand, still need help. I don't think I treat content as a string, rather, in my code, I treat *content as an address pointing to a string. I thought that's how address works, is it not? And why (counter + 1) is a string thinking? Counter is an int.
comment
pset6 server trapped in if (connected())
I think I am a step closer. My parse function passes all the server1 check. Therefore I run it with gdb again, this time with the break point at load. It turns out load function execute "while (fread(buffer, 1, 1, file) == 1)" twice before "counter = counter + 1;". I think here is the problem. But cant see why fread is run twice. After load, gdb keeps running, in the end it reads: Program received signal SIGPIPE, Broken pipe. 0x00007ffff77fa710 in __write_nocancel () at ../sysdeps/unix/syscall-template.S:81 81 ../sysdeps/unix/syscall-template.S: No such file or directory.