C++ 질문하나만요!
글쓴이: qpst1024 / 작성시간: 화, 2013/11/05 - 9:26오후
----------------------------------------------------------
// 데이터 받기
retval = recv(client_sock, buf, BUFSIZE, 0);
if(retval == SOCKET_ERROR){
err_display("recv()");
break;
}
else if(retval == 0)
break;
// 받은 데이터 출력
buf[retval] = '\0';
printf("[TCP/%s:%d] %s\n", inet_ntoa(clientaddr.sin_addr),
ntohs(clientaddr.sin_port), buf);
----------------------------------------------------------
서버/클라이언트를 이용해 통신연습을 하고있습니다
갑자기 궁금한게 생겼는데 클라이언트에서 보낸 데이터(buf)를
데이터받기/출력 사이에 정수형으로 받아들일 수 없나요?
Forums:
http://forum.falinux.com/zbxe
http://forum.falinux.com/zbxe/index.php?document_srl=408129&mid=C_LIB
buf가 char형이고 buf안의 내용이 모두 숫자라는 가정하에
atoi()함수를 사용하면 되지 않을까요?
atoi보니 itoa란것도 있네요 역시 프로그래밍은
atoi보니 itoa란것도 있네요
역시 프로그래밍은 공부해도 끝이 없나봅니다
덕분에 itoa도 얻어가서 정말 감사합니다!
시리즈로 atof, atol, atoll 등도
시리즈로 atof, atol, atoll 등도 있어요~
같이 확인해 두시면 나중에 도움이 될거같네요.
댓글 달기