int main(int argc, char *argv[]) { if (argc < 2) { perror("argument less"); exit(EXIT_FAILURE); } initGrid(argv[1]); int sfd; char ip[32]; memset(ip, 0, 32); int port = 0; Msg msg_recv; memset(&msg_recv, 0, sizeof(Msg)); if (atoi(argv[1]) == 1) { sfd = initUdpServer(IP, PORT); while (recvFrom(sfd, &msg_recv, sizeof(Msg), ip, &port) != 0) { hebing(&msg_recv); if (win(msg_recv)) { printf("YOU LOSE!\n"); break; } move(); sendTo(sfd, &msg, sizeof(Msg), ip, port); if (win(msg)) { printf("YOU WIN!\n"); break; } } } else { sfd = initUdpClient(); while (move(), sendTo(sfd, &msg, sizeof(Msg), IP, PORT) != 0) { if (win(msg)) { printf("YOU WIN\n"); break; } recvFrom(sfd, &msg_recv, sizeof(Msg), ip, &port); hebing(&msg_recv); if (win(msg_recv)) { printf("YOU LOSE!\n"); break; } } } close(sfd); return 0; }
int main(void) { Node* list1 = init_list(10); Node* list2 = init_list(12); Node* h = list1; Node* p = list2; printf("list1的值:\n"); while(h!=NULL) { printf("%d\t",h->value); h = h->next; } printf("-----------\n"); printf("list2的值:\n"); while(p != NULL) { printf("%d\t",p->value); p = p->next; } printf("-----------\n"); //Node* h = (Node*)calloc(1,sizeof(Node)); Node* temp = hebing(list1,list2); printf("hebingzhihou-\n"); Node* head = temp; while(head!=NULL) { printf("%d\t",head->value); head = head->next; } printf("\n============\n"); return 0; }