230400byte를 파일에서 읽어야 합니다.

andro000의 이미지

230400 byte를 파일에서 읽어야 합니다.

그런데 18810 byte밖에 읽어오지 못하네요.

좋은 방법이 없을까요.?

pynoos의 이미지

읽지 못하는 증상이 어떤지 자세히 남겨주세요.

block 되는지, error가 나오는지, error 메시지나 errno는 어떻게 되는지.

펑키의 이미지

읽는 방법을 한번 올려놔줘 보세요.

어떤 함수를 이용해서 읽으시는지 혹은 read나 이런 함수를 이용
하시면 몇 바이트를 읽었는지 리턴을 해주니깐 통신에서 이용하는
유틸리티 함수 같이 내가 원하는 바이트 까지 읽을때 까지 루프를
돌리는 방법은 어떨까요.?

가장 확실한것은 읽는 부분만 소스를 한번 올려놔줘보세요.

즐거운 하루 되세요.

andro000의 이미지

읽을때 이렇게 읽습니다.

if((cnt = fread(oTemp, sizeof(char), 230400, fpread)) != 230400) {
printf("read error\n");
return -1;
}

초보인즉, 모르는게 죄가 아니요. 열심히 배우려하지 않는게 죄인지 알고
쉬운 답이더라 답변 꼭 부탁드립니다.

정보 공유 하길 원하는 andro000

mangg의 이미지

ㅠㅠ

oTemp는 230400 을 담을수 있는 그릇은 되나요??
ㅠㅠ

그냥 반복해서 읽어여 ㅡㅡ;

while( 230400 이 안된다면 true )
{
nRead = fread( .................... );
if( nRead == -1 ) 에러처리.
}

-------------------
나는 Copy&Paster 이다. 나의 화려한 기술 조합에 모두들 나를 두려워 한다. 나도 코드 Maker 이고 싶다.

체스맨의 이미지

andro000 wrote:
읽을때 이렇게 읽습니다.

if((cnt = fread(oTemp, sizeof(char), 230400, fpread)) != 230400) {
printf("read error\n");
return -1;
}

초보인즉, 모르는게 죄가 아니요. 열심히 배우려하지 않는게 죄인지 알고
쉬운 답이더라 답변 꼭 부탁드립니다.

두가지 정도 일단 체크 해보셔야 될 것 같네요.
첫째 파일 크기가 230400 이 안된다. 이게 아니라면,
둘째, fopen 두번째 인자를 "rb" 가 아니라, "r" 또는 "rt" 로 했다.

Orion Project : http://orionids.org

godyang의 이미지

안녕하세요?

"rb"옵션(Read - Binary)은 윈도우 비쥬얼 스튜디오용 옵션이 아닌가요?

그럼...

체스맨의 이미지

godyang wrote:
안녕하세요?

"rb"옵션(Read - Binary)은 윈도우 비쥬얼 스튜디오용 옵션이 아닌가요?

그럼...

작업 환경에 대한 언급이 없으셔서 일단 확인해 보시라고 말씀드렸습니다.
:)

아, 그리고 만일 유닉스 및 윈도 등에서도 호환성을 보장받기 위해서는
이진 파일은 "r" 보다는 "rb" 로 여는 게 좋습니다.

Orion Project : http://orionids.org

andro000의 이미지

rb로 153600 byte를 읽었습니다.

153600 byte 읽기를 원했습니다.

rb 모드 : read-binary모드로 열때 정확한 153600 byte를 읽고
r 모드 : read 모드로 열때는 18810 byte를 읽었는데

두가지 모드 차이점이 어디에 있나요? 궁금합니다.

정보 공유 하길 원하는 andro000

godyang의 이미지

안녕하세요?

MSDN의 내용을 인용하겠습니다.

Quote:

------------------------------
In addition to the above values, the following characters can be
included in mode to specify the translation mode for newline characters:

t
Open in text (translated) mode. In this mode, CTRL+Z is interpreted as
an end-of-file character on input. In files opened for reading/writing
with "a+", fopen checks for a CTRL+Z at the end of the file and removes
it, if possible. This is done because using fseek and ftell to move
within a file that ends with a CTRL+Z, may cause fseek to behave
improperly near the end of the file.
Also, in text mode, carriage return–linefeed combinations are
translated into single linefeeds on input, and linefeed characters are
translated to carriage return–linefeed combinations on output. When a
Unicode stream-I/O function operates in text mode (the default), the
source or destination stream is assumed to be a sequence of multibyte
characters. Therefore, the Unicode stream-input functions convert
multibyte characters to wide characters (as if by a call to the mbtowc
function). For the same reason, the Unicode stream-output functions
convert wide characters to multibyte characters (as if by a call to the
wctomb function).

b
Open in binary (untranslated) mode; translations involving carriage-
return and linefeed characters are suppressed.
If t or b is not given in mode, the default translation mode is defined
by the global variable _fmode. If t or b is prefixed to the argument,
the function fails and returns NULL.

For more information about using text and binary modes in Unicode and
multibyte stream-I/O, see Text and Binary Mode File I/O and Unicode
Stream I/O in Text and Binary Modes.
------------------------------

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.