데이터 자료 읽기

익명 사용자의 이미지

data.txt

a  b  c      d   e  f     g     h     i     j
23 24 47.766 +61 35 30.73 13.39 14.70 14.06 13.06
23 24 48.856 +61 35 25.23       21.25       18.51
23 24 49.679 +61 35 30.92 19.64 21.88       18.81
23 24 47.333 +61 35 48.76 18.71             18.28

대략 저런 자료를 c언어로 읽어올려는데

g열이나 h i 열처럼 중간에 빈칸이 있습니다

저 텍스트 파일을 열어 열마다 각각의 변수에 넣고 싶은데
fscanf 를 썻을땐 공백은 그냥 넘어가버리고 다음껄 읽더라고요

#define format1 &a, &b, &c, &d, &e, &f, &g, &h, &i, &j

fscanf(fp,"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf \n",format1);

2번째 줄을 읽으면 g는 빈칸이라 그냥 넘어가고 변수g에 h값이 들어가더라고

어떻게 읽어와야하는걸까요?

작성자입니다.의 이미지

23 24 47.766 +61 35 30.73 13.39 14.70 14.06 13.06

23 24 48.856 +61 35 25.23 21.25 18.51

23 24 49.679 +61 35 30.92 19.64 21.88 18.81

23 24 47.333 +61 35 48.76 18.71 18.28

작성자의 이미지

그냥 사진으로 올립니다.

댓글 첨부 파일: 
첨부파일 크기
Image icon 캡처.PNG5.65 KB
김정균의 이미지

데이터나 코드는 <code>~</code> 블럭을 사용하시면 됩니다. 글 등록할 때 textarea 위에 적혀 있습니다.

익명 사용자의 이미지

중간에 공백이 있는 열과 없는 열의 차이점은 무엇인가요? 단지 공백 개수의 차이인가요?

작성자의 이미지

별(성단)의 관측 자료인데 관측자료가 없는건 그냥 공백으로 표시되더라고요
뒤에서 4개의 열만 공백이있습니다.
뒤에 4개열 빼고는 앞에 6개 열에는 공백이 전혀 없고 뒤에 4개열에 대한 각각의 공백 갯수는 저도 잘 모르겠네요
데이터를 인터넷에서 가져온거라 천줄이 가깝기도 하고

익명 사용자의 이미지

공백이 있는 열과 없는 열의 차이를 어떻게 하면 함수가 알 수 있을 지 잘 생각해 보세요. 그 중 간단한 방법이 공백 개수 차이입니다.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.