주석처리 도움을 받고 싶습니다.
딥공감
질문 제목 :주석 도움을 좀 받을 수 있을까요?질문 요약 :소스코드 주석 분석질문 내용 : 소스코드를 받았습니다 그런데 학습했던 부분이 아니라서 그냥 공부용으로 받은거였는데
책에서 어느 부분에서 나오는지도 전혀 감히 잡히지 않습니다. 주석 표기를 해서 어느부분을 어떻게
공부 하면 되는것인지 좀 알고싶어서 이렇게 질문 글을 남겼습니다.========== 소스코드 ==========#include stdio.h
#include stdlib.h
#include conio.h
#include string.hvoid plus();
void modify();
void Delete();
void print();
void ohoh();
void input();
struct EMP{
int hak;
char name[20];
int age;
char addr[50];
struct EMP *next;
}*ptr,*head,*tail,*prev,*x;int Q; main()
{
head = tail = NULL;
while(1){
system(cls);
printf(1. 항목 추가\n);
printf(2. 항목 수정\n);
printf(3. 항목 삭제\n);
printf(4. 현황\n);
printf(5. 검색\n);
printf(6. 6월 18일 추가한것 input\n);
printf(7. 종료\n);
printf(◐◐◐◐원하시는 작업선택 ============▶ );
scanf(%d,&Q);
fflush(stdin);
switch(Q){
case 1 : system(cls);
plus();
break;
case 2 : modify();
break;
case 3 : Delete();
break;
case 4 : print();
break;
case 5 : ohoh();
break;
case 6 : input();
break;
case 7 : return;
break;
}
}
getch();
}
////////////////추가//////////////////
void plus()
{
while(1){ ptr=(struct EMP*)malloc(sizeof(struct EMP));
if(ptr==NULL){
printf(할당오류!);
exit(1);
}
printf(학번 : (0을 누르면 종료합니다));
scanf(%d,&ptr-hak);
fflush(stdin);
if(ptr-hak==0){
break;
} printf(이름 : (end을 누르면 종료합니다));
gets(ptr-name);
printf(나이 : );
scanf(%d,&ptr-age);
fflush(stdin); printf(주소 : );
gets(ptr-addr);
ptr-next=NULL;
printf(입력이 완료되었습니다.\n);
if(head==NULL){ //1번째
head=tail=ptr;
}else { //그다음꺼부터
prev=tail;
tail-next=ptr;
tail=ptr;
}
}
printf(입력을 종료합니다);
free(ptr);
}
////////////////수정//////////////////
void modify()
{
int hak,num,found;
printf(수정할 학번 입력);
scanf(%d,&num);
found=1;
ptr=head;
//num=0;
while(ptr){
if(ptr-hak == num){
printf(나이 : );
scanf(%d,&ptr-age);
fflush(stdin);
printf(주소 : );
gets(ptr-addr);
ptr=ptr-next;
printf(수정완료!);
} found=0;
ptr=ptr-next;
}//while
if(found==1){
printf(없는 학번);
}
}
////////////////삭제 p472//////////////////
void Delete()
{
int found,hak; printf(삭제할 학번을 입력하세요);
scanf(%d,&hak);
fflush(stdin);
found=1;
ptr=head; while(ptr){
if(hak==ptr-hak){
if(ptr==head){
head=ptr-next;
}else if(ptr==tail){
prev-next=NULL;
tail=prev;
}else{
prev-next=ptr-next;
}
found=0;
free(ptr);
break;
} prev=ptr;
ptr=ptr-next;
printf(삭제 완료되었습니다);
}//while 끝
if(found==1){
printf(not found!!\n);
}
ptr=head; getch();
}
////////////////출력//////////////////
void print()
)
{
ptr=head;
printf( 학번 이름 나이 주소\n);
while(ptr){
printf(%7d %7s %7d %7s\n,ptr-hak,ptr-name,ptr-age,ptr-addr);
ptr=ptr-next;
}
getch();
}
/////////////검색 p468//////////////////
void ohoh()
{
//char s_name[20];
int found,hak; ptr=head;
printf(검색할 학번을 입력하세요);
scanf(%d,&hak);
found=1;
ptr=head;
while(ptr){
if(hak==ptr-hak){
printf(%7d %7s %7d %7s\n,ptr-hak,ptr-name,ptr-age,ptr-addr);
found=0;
}
ptr=ptr-next;
}
if(found==1){
printf(not found);
}
}////////////////입력2/////////////////////
void input()
{
while(1){ ptr=(struct EMP*)malloc(sizeof(struct EMP));
if(ptr==NULL){
printf(할당오류!);
exit(1);
}
printf(학번 : (0을 누르면 종료합니다));
scanf(%d,&ptr-hak);
fflush(stdin);
if(ptr-hak==0){
break;
} printf(이름 : );
gets(ptr-name); printf(나이 : );
scanf(%d,&ptr-age);
fflush(stdin); printf(주소 : );
gets(ptr-addr);
ptr-next=NULL;
if(head==NULL){
head=ptr;
}else{
x=head; //--------------------중복검사------------------//
while(x){ if(x-hak == ptr-hak ){
printf(중복입니다.\n);
free(ptr);
}else if (x-hak ptr-hak){
prev=x;
x=x-next;
}else{
break;
}
}//while
if(head==x){
ptr-next=x;
head=ptr;
}else if(x==NULL){
prev-next=ptr;
}else{
prev-next=ptr;
ptr-next=x;
}
}
}//while
free(ptr);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692424 | 2차원배열 자료입력질문이요! (1) | 똘끼 | 2025-04-22 |
2692401 | 유닉스안에서 C언어를 이용한 명함 만들기 입니다; 이해안가는 부분이있네요 | 2gether | 2025-04-22 |
2692374 | 고수님들 댓글 마니부탁해요!!! (2) | 엄지 | 2025-04-22 |
2692343 | scnaf에 자꾸 선언을 참조하라는데;; (8) | 도래 | 2025-04-22 |
2692282 | 도스상에서 생성된 exe파일에 press~ 뜨게 하기 (4) | 회사원 | 2025-04-21 |
2692256 | scanf("%*c"); ㅠㅠ 고수님들 | 거북이 | 2025-04-21 |
2692230 | 하노이탑 질문입니다. (1) | 미쁘다 | 2025-04-21 |
2692210 | 정보 올림피아드 문제인데.. 풀이 과정이 궁금합니다.(재귀함수) (5) | 물티슈 | 2025-04-20 |
2692144 | C언어와 리눅스에 대한 질문입니다. | 싴흐한세여니 | 2025-04-20 |
2692114 | 컨텍스트 스위칭하는데 걸리는 시간 측정.. | YourWay | 2025-04-19 |
2692086 | 간접참조 연산자, 증감연산자 질문이용! (2) | 블랙캣 | 2025-04-19 |
2692056 | 주석좀 달아주세요. 몇개적엇는데 몇개만달아주세요. (2) | DevilsTears | 2025-04-19 |
2691978 | 진수 쉽게 이해하는법... (3) | 지지않는 | 2025-04-18 |
2691949 | getchar() 한 문자를 입력받는 함수 질문 | 채꽃 | 2025-04-18 |
2691919 | 배열 정렬 및 합치기 질문입니다. | 사과 | 2025-04-18 |
2691845 | c언어왕초보 질문이 있습니다........ | 루나 | 2025-04-17 |
2691815 | void add(int num); 함수... (4) | 살랑살랑 | 2025-04-17 |
2691756 | 명령 프롬프트 스크롤바가 없어요 | 두메꽃 | 2025-04-16 |
2691725 | 자료구조에 관련해서 질문이 있어 글을 올립니다. | 누리알찬 | 2025-04-16 |
2691697 | if 문에서 구조체 배열에 저장되있던 문자열 검사하는 법 ? (2) | 민트맛사탕 | 2025-04-16 |