int로 변환하고 싶은 다음과 같은 것을 가지고 있습니다.C에서 문자열을 int로 변환하는 방법
char *ptr; // this can point to variable length of string
int balance = functionToConverIntoint(ptr)
이 작업을 수행 할 수있는 "functionToConverIntoint"에는 이러한 함수가 있습니까?
int로 변환하고 싶은 다음과 같은 것을 가지고 있습니다.C에서 문자열을 int로 변환하는 방법
char *ptr; // this can point to variable length of string
int balance = functionToConverIntoint(ptr)
이 작업을 수행 할 수있는 "functionToConverIntoint"에는 이러한 함수가 있습니까?
strtol() 및 strtoul()을 확인하십시오.
"0"문자열과 유효하지 않은 숫자를 구별하는 좋은 방법이 없으므로 atoi()를 사용하지 않으려합니다.
strtol에는 3 개의 인수가 있습니다. strtoul에는 2를 입력해야합니다. – itsaboutcode
좋아, 고마워. 내가 문자열을 부동으로 변환 할 수있는 함수를 말해 줄 수 있니? – itsaboutcode
'strtod()'- 확인 http://linux.die.net/man/3/strtod – pmg
balance = atoi(ptr)
예. atoi
은 매우 제한된 오류 처리 기능이있는 기본 기능입니다. strtol
이 더 좋습니다.
혹시이/try/try stackoverflow에서 검색 했습니까? – wilhelmtell
예치하지만 나는 C 솔루션에 대해 논하지 않았습니다. – itsaboutcode
@itsaboutcode : 그저 잘못되었습니다. 죄송합니다. http://stackoverflow.com/search?q=[c]+string+to+int –