Linux C. 구조체 정의와 관련, 제가 뭘 잘못했을까요?
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 ;
이 부분이 죽어도 컴파일이 안됩니다. 
제가 너무 기초가 약한 건가요. 도와주세요. 끝.
추기 : 소스는 너무 지저분해서 못 올리겠습니다. -.-


alay 는 layout 타입이고 direntp->d
alay 는 layout 타입이고 direntp->d_name 은 (direntp 가 C의 dirent 구조체의 포인터인 것 같으니) char의 배열이라 char * 로 처리될 텐데, layout = direntp->d_name 이건 무엇을 의도한 것인가요? 이게 컴파일이 되면 그것도 이상할 것 같습니다만.
layout 내의 특정 필드에 파일명을 복사하고 싶은 거라면 strcpy( alay.imgpath, direntp->d_name ) 이런 식으로 하시면 되겠네요.
좋은 하루 되세요!
감사합니다. 그렇게 해볼께요.
"="이 아니라 strcpy를 써야 한다는 걸 어디서 보긴 봤는데... -.-
이게 layout이 사용자 정의된 타입이기 때문이죠?
아침부터 우분투는 손님 계정으로 떠서 버팅기고 8:50분 부터 헤메서 이제 살아났습니다.
수고해세요. 끝.
댓글 달기