2013-12-17 3 views
1

프로그램을 실행하고이 코드 집합의 구조에 대한 데이터를 입력 할 때 입력하려는 데이터로 1을 입력하면 항상 오류가 발생합니다. 다시 같은 숫자를 입력해도 작동하는 것 같습니다. 나는 코드의이 부분이되도록 그것을 분리했다.유효성 검사 오류가 항상 먼저 발생합니다.

아무도 도와 드릴 수 있습니까?

do{ 
    puts("What is the packet type?"); 
    if(scanf(" %d", &records[*rCount].type) == 1 
     && records[*rCount].type >= 0 
     && records[*rCount].type <= 10) 
    { 
     valid = 1; 
    } 
    else 
    { 
     valid = 0; 
     getchar(); 
     puts("\nNot a valid input"); 
    } 
}while(valid!=1); 

구조 정의 :

struct packet{ // declare structure for packet creation 
    int source; 
    int destination; 
    int type; 
    int port; 
    char data[51]; 
}; 
+0

구조가 어떻게 달라졌습니까? – rullof

+0

구조체로 업데이트 됨 – user3103598

+0

'records []'표시 – chux

답변

1

문제 struct packet records에서 할당 오류 것으로 보인다.

관련 문제