질문과 답변

기 타 C언어 질문드립니다.ㅠㅠ

2014.06.01 13:39

천마_ 조회:1929

--------------------Configuration: c13_3_3 - Win32 Debug--------------------
Compiling...
c13_3_3.cpp
C:\CLan\ch13_3\c13_3_3.cpp(5) : error C2143: syntax error : missing ';' before 'for'
C:\CLan\ch13_3\c13_3_3.cpp(5) : error C2143: syntax error : missing ')' before ';'
C:\CLan\ch13_3\c13_3_3.cpp(5) : error C2143: syntax error : missing ';' before '<'
C:\CLan\ch13_3\c13_3_3.cpp(5) : error C2501: 'i' : missing storage-class or type specifiers
C:\CLan\ch13_3\c13_3_3.cpp(5) : error C2086: 'i' : redefinition
C:\CLan\ch13_3\c13_3_3.cpp(5) : error C2143: syntax error : missing ';' before '<'
C:\CLan\ch13_3\c13_3_3.cpp(5) : error C2143: syntax error : missing ';' before '++'
C:\CLan\ch13_3\c13_3_3.cpp(5) : error C2501: 'i' : missing storage-class or type specifiers
C:\CLan\ch13_3\c13_3_3.cpp(5) : error C2086: 'i' : redefinition
C:\CLan\ch13_3\c13_3_3.cpp(5) : error C2143: syntax error : missing ';' before '++'
C:\CLan\ch13_3\c13_3_3.cpp(5) : error C2059: syntax error : ')'
C:\CLan\ch13_3\c13_3_3.cpp(6) : error C2447: missing function header (old-style formal list?)
C:\CLan\ch13_3\c13_3_3.cpp(10) : error C2143: syntax error : missing ';' before '}'
C:\CLan\ch13_3\c13_3_3.cpp(10) : error C2143: syntax error : missing ';' before '}'
C:\CLan\ch13_3\c13_3_3.cpp(10) : error C2143: syntax error : missing ';' before '}'
C:\CLan\ch13_3\c13_3_3.cpp(13) : error C2086: 'i' : redefinition
C:\CLan\ch13_3\c13_3_3.cpp(14) : error C2143: syntax error : missing ';' before 'for'
C:\CLan\ch13_3\c13_3_3.cpp(14) : error C2143: syntax error : missing ')' before ';'
C:\CLan\ch13_3\c13_3_3.cpp(14) : error C2143: syntax error : missing ';' before '<'
C:\CLan\ch13_3\c13_3_3.cpp(14) : error C2501: 'i' : missing storage-class or type specifiers
C:\CLan\ch13_3\c13_3_3.cpp(14) : error C2086: 'i' : redefinition
C:\CLan\ch13_3\c13_3_3.cpp(14) : error C2143: syntax error : missing ';' before '<'
C:\CLan\ch13_3\c13_3_3.cpp(14) : error C2143: syntax error : missing ';' before '++'
C:\CLan\ch13_3\c13_3_3.cpp(14) : error C2501: 'i' : missing storage-class or type specifiers
C:\CLan\ch13_3\c13_3_3.cpp(14) : error C2086: 'i' : redefinition
C:\CLan\ch13_3\c13_3_3.cpp(14) : error C2143: syntax error : missing ';' before '++'
C:\CLan\ch13_3\c13_3_3.cpp(14) : error C2059: syntax error : ')'
C:\CLan\ch13_3\c13_3_3.cpp(15) : error C2447: missing function header (old-style formal list?)
C:\CLan\ch13_3\c13_3_3.cpp(27) : error C2143: syntax error : missing ';' before '}'
C:\CLan\ch13_3\c13_3_3.cpp(27) : error C2143: syntax error : missing ';' before '}'
C:\CLan\ch13_3\c13_3_3.cpp(27) : error C2143: syntax error : missing ';' before '}'
C:\CLan\ch13_3\c13_3_3.cpp(30) : error C2065: 'px' : undeclared identifier
C:\CLan\ch13_3\c13_3_3.cpp(30) : error C2100: illegal indirection
C:\CLan\ch13_3\c13_3_3.cpp(30) : error C2440: 'initializing' : cannot convert from 'int' to 'struct addr_rec'
        No constructor could take the source type, or constructor overload resolution was ambiguous
C:\CLan\ch13_3\c13_3_3.cpp(31) : error C2501: 'px' : missing storage-class or type specifiers
C:\CLan\ch13_3\c13_3_3.cpp(31) : error C2040: 'px' : 'int *' differs in levels of indirection from 'int'
C:\CLan\ch13_3\c13_3_3.cpp(31) : error C2065: 'py' : undeclared identifier
C:\CLan\ch13_3\c13_3_3.cpp(31) : error C2100: illegal indirection
C:\CLan\ch13_3\c13_3_3.cpp(31) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\CLan\ch13_3\c13_3_3.cpp(32) : error C2501: 'py' : missing storage-class or type specifiers
C:\CLan\ch13_3\c13_3_3.cpp(32) : error C2040: 'py' : 'int *' differs in levels of indirection from 'int'
C:\CLan\ch13_3\c13_3_3.cpp(32) : error C2440: 'initializing' : cannot convert from 'struct addr_rec' to 'int *'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.

c13_3_3.exe - 42 error(s), 0 warning(s)

 

 

소스

#include<myheader.h>

void print_all(struct addr_rec *p);
   int i;
   for(i = 0; i < ADDRMAX; i++);
   {
      printf("%s %s\t", p->name.l_name, p->name.f_name);
      printf("%s\t%s\n", p->tel, p->city);
   }
};

void sort(struct addr_rec *p);
   int i, j, m;
   for(i = 0; i<ADDRMAX-1; i++);
   {
      m = i;
      for(i = 0; i < ADDRMAX; i++)
   {
         int cmp = strcmp((p+m)->name.l_name, (p+j)->name.l_name);
         if(!cmp){ //성이 같으면 이름으로 비교
            if(strcmp((p+m)->name.f_name, (p+j)->name.f_name)) m = j;
         };
         else if (cmp > 0) m = j;
      }
      if(m != i) swap(p+m, p+i);
   }
};

void swap(struct addr_rec *px, struct addr_rec *py);
   struct addr_rec tmp = *px;
   *px = *py;
   *py = tmp;

void main() {
 struct addr_rec persons[ADDRMAX] = {
  {{"박", "철수"}, "4788-8936", "성남시"},
  {{"김", "인수"}, "3024-6830", "부산시"},
  {{"박", "영희"}, "5023-5849", "강릉시"},
  {{"이", "인수"}, "5034-2378", "서울시"},
  {{"홍", "길동"}, "2034-5082", "인천시"},
 };
 sort(persons);
 print_all(persons);
}

번호 제목 글쓴이 조회 등록일
[공지] 질문과 답변 게시판 이용간 유의사항 gooddew - -
49993 소프트웨어| 내용으로 파일검색하는 프로그램 문의 [1] 운상아짜 1023 06-26
49992 윈 도 우| 외장 하드 꽂은 채로 포맷해도 상관없나요? [4] 팔란도 1274 06-26
49991 윈 도 우| F11 Boot Manager 문의 [2] 낙엽 1629 06-26
49990 하드웨어| 이게 무슨 듯인가요?? [6] ㄷㄱ 2029 06-26
49989 윈 도 우| 노트북 포맷 준비물.. [5] 손재주 1972 06-26
49988 소프트웨어| 비트디펜더 인터넷시큐리티 2014 설정법 좀 알려주세요. [2] 한걸음 1908 06-26
49987 기 타| 고수님들 도와주세요... [3] 멘살 1093 06-26
49986 윈 도 우| USB 3.0 포트 작동여부 확인 방법이 있나요> [5] 솔모로 2542 06-26
49985 윈 도 우| 급하게 질문 하나만 드릴게요~! [3] 마로야 1001 06-26
49984 하드웨어| 파워내부의 쿨러 질문.. [4] 태사자 955 06-26
49983 윈 도 우| 윈도우8.1 폴더생성시 속성 [2] 나그네_K 1155 06-26
49982 윈 도 우| 윈도우 8.1 다들 백신 뭐쓰시나요? [15] 흑노 2623 06-26
49981 기 타| 헤드폰 전문가님?? 헤드폰 추천 좀.. [5] 눅스야 1176 06-25
49980 하드웨어| USB 사운드 카드.. 이상해요 [4] 눅스야 1042 06-25
49979 하드웨어| 라데온 HD7770 DVI 듀얼 질문입니다 [1] neonchang 1035 06-25
49978 소프트웨어| 비트디펜더 .. 예외사이트 설정 어떻게 하나요? 코나 1648 06-25
49977 윈 도 우| lg 일체형(v220) 입니다. gpt를 mbr방식으로 바꾸고싶어요 [1] 돼랑이00 1351 06-25
49976 윈 도 우| 컴맹인데요... 윈도우8.1에서는영화볼때 무슨플레이어 써야... [6] 윈도우8.1 1730 06-25
49975 윈 도 우| USB 3.0 복사 속도 [4] 솔모로 2558 06-25
49974 소프트웨어| os 없는 컴퓨터에 고스트나 트루이미지로 부팅 가능 한가요? [5] 뿜뿡 1731 06-25
XE1.11.6 Layout1.4.8