Linux C. 구조체 정의와 관련, 제가 뭘 잘못했을까요?

smreo의 이미지

main 함수 안에 이런 구조체를 만들었습니다.

typedef struct File_layout /* No need, unitl now -.- */
{
char shttime [12] ; /* image shooted time yyyymmddhhmmssmm */
char carno [20] ; /* car plateno */
char camip [12] ; /* camera IP address */
char cardrctn [1] ; /* car's direction : U,D,M and son on */
char latcrdnt [1] ; /* latitude dep : S, N */
char latval [7] ; /* latitude coordinate */
char lngcrdnt [1] ; /* longitude dep : E, W */
char lngval [7] ; /* longitude coordinate */
int carpace ; /* car's pace : speed */
char camtype [20] ; /* camera type... */
char imgpath [300] ; /* image path in local box*/
} layout ;

layout alay ;
layout* play ;

그리고 특정 디렉토리를 읽어서... 파일 명을 위의 구조체에 전달해서 쓰려고 합니다.
원하는 디렉토리에 들은 파일 명(direntp->d_name)을 읽어서 주욱 찍는 것까지 실행해보고...,
필요에 따라 play->shttime 혹은 alay.shttime, 이렇게 쓸 요량으로 책 봐가면서
위의 구조체를 추가했는데요.

alay = direntp->d_name ;
play = &alay ;

이 부분이 죽어도 컴파일이 안됩니다.
제가 너무 기초가 약한 건가요. 도와주세요. 끝.

추기 : 소스는 너무 지저분해서 못 올리겠습니다. -.-

raymundo의 이미지

alay 는 layout 타입이고 direntp->d_name 은 (direntp 가 C의 dirent 구조체의 포인터인 것 같으니) char의 배열이라 char * 로 처리될 텐데, layout = direntp->d_name 이건 무엇을 의도한 것인가요? 이게 컴파일이 되면 그것도 이상할 것 같습니다만.

layout 내의 특정 필드에 파일명을 복사하고 싶은 거라면 strcpy( alay.imgpath, direntp->d_name ) 이런 식으로 하시면 되겠네요.

좋은 하루 되세요!

smreo의 이미지

"="이 아니라 strcpy를 써야 한다는 걸 어디서 보긴 봤는데... -.-
이게 layout이 사용자 정의된 타입이기 때문이죠?

아침부터 우분투는 손님 계정으로 떠서 버팅기고 8:50분 부터 헤메서 이제 살아났습니다.
수고해세요. 끝.

댓글 달기

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