gethostbyname() 함수 /* 도메인 네임 -> 32비트 IP주소 할 때, gethostbyname() 함수를 사용한 프로그램*/ #include #include #include #include int main(int argc, char *argv[]) { struct hostent *myhost; struct in_addr myinaddr; //IP 주소를 저장할 구조체 int i; if(argc h_name); //호스트이름 출력 i = 0; while(myhost->h_aliases[i] != NULL) { printf("aliases name : \t\t\t%s\n", myhost->h_aliases[i]); //호스트별명 출력 i++; } printf("host address type : \t\t%d\n", myhost.. 더보기 inet_ntoa() 함수 /*인터넷 주소를 표시할 수 있는 3가지 방식중, 32비트 IP주소 -> dotted decimal 할 때, inet_ntoa()함수를 사용한 프로그램*/ #include #include #include #include #include #include #include int main(int argc, char *argv[]) { char *haddr; struct in_addr host_ip; if(argc dotted decimal*/ printf("dotted decimal Address : %s\n", inet_ntoa(host_ip)); return 0; } 더보기 2차원 배열을 초기화하여, 화면에 출력 #include int main() { int i, j; int array[3][4] = {{15, 23, 45, 56}, {34, 52, 76, 23}, {43, 62, 91, 84}}; for(i=0; i 더보기 이전 1 ··· 21 22 23 24 25 26 27 ··· 98 다음