[완료]구조체 사용에 대해서... 질문요
글쓴이: nayangachi / 작성시간: 목, 2009/07/09 - 12:05오후
typedef struct _CONTENTS_
{
char sPNAME[2048];
char sOP1[2048];
char sOP2[2048];
char sOP3[2048];
char sOP4[2048];
}_CONTENTS;위와 같은 구조체를 a.h라는 헤더파일에 작성하고
for(...)
{
if ((lineINFO[i] == ' ') && (istart == 0))
{
istart = i+1;
memset(stemp, 0, sizeof(stemp));
strcpy(stemp, lineINFO +istart);
printf("PRONAME[%s]\n",stemp);
itempstart =0;
itempend =0;
jtemp =0;
for(j = 0; j <= strlen(stemp); j++)
{
if (((stemp +j == ' ') && (itempstart == 0)) || strlen(stemp)-1 ==j)
{
itempstart = 1;
jtemp = j ;
printf("%d\n",j);
1 ===> strcpy(gContents->sPNAME, stemp);
printf("%d\n",j);
printf("2 PRONAME[%d]=[%s], stemp=[%s]\n", jtemp ,gContents->sPNAME, stemp);
}....
이렇게 작성하였는데 ..
컴파일은 에러가 없으나
실행하면 1이라는 부분에서 에러가 발생하는데 어떻게 처리 해야 하는것일까요?
C초보라.. 간단한것도 무지 길게 짜서...... 힘드네요 ㅋㅋ
Forums:


...
segmentation fault 같군요(OS 가 MS 라면 Access Violation) lineINFO 메모리도 깨지는 것같고 무엇보다 gContents->sPNAME 변수에 메모리 malloc 제대로 잡아줬는지 확인해주세요
-----
안녕하세요 소프트웨어 공학센터 장원석 책임입니다.
http://www.software.kr
ㅎㅎ 그렇군요
ㅎㅎ 그렇군요 감사합니다^^;
댓글 달기