strtok 에 대해서 설명좀..ㅠㅠ
먹딸기
strtok 예제 문제인데, 이해가 잘 안되요.. 질문 내용 :
우선 소스가 이거구요.
#include stdio.h
#include string.h
void main()
{
char str[]=i am a boy,you are a girl;
char *p;
p=strtok(str, ,);
while (p!= null) {
puts(p);
p=strtok(null, ,);
}
}
여기서 while 문이 이해가 안되거든요...;;
특히 p=strtok(null, ,); 이 문장이 이해가 안되요-_-;;
쉽게 설명 좀 해주실분~~ ㅠㅠ
-
황소숨
외우는게 아니라 편의를 위해 알아야하는거죠 ㅋㅋ
-
즐겨찾기
3. If the search does not find an element, the function stores the address of the terminating null character in the internal static-duration object. Otherwise, it stores a null character in the element whose address is end. Then it stores the address of t
-
유희
2. If the search does not find an element, the function stores the address of the terminating null character in the internal static-duration object (so that a subsequent search beginning with that address will fail) and returns a null pointer. Otherwise,
-
여자
1. The function searches the string for begin, the address of the first element that equals none of the elements of the string s2 (a set of token separators). It considers the terminating null character as part of the search string only.
-
한누리
strtok
char *strtok(char *s1, const char *s2);
If s1 is not a null pointer, the function begins a search of the string s1. Otherwise, it begins a search of the string whose address was last stored in an internal static-duration object on an earlier call -
가람
아 그냥 거의 외워야 하는건가요?? 아직도 잘 이해가 되지는 않지만 답변 달아주셔서 감사합니다^^ 계속 생각해봐야겠어요
-
찬솔
strtok함수에 첫번째 인자에 NULL이 들어갔을 경우는 이전에 토큰을 나누던 문자열을 그대로 쓰겠다는 표시로 보시면 됩니다.
처음 p=strtok(str,\ ,\);로 str문자열에서 공백과 ,을 구분자로 토큰을 나누고 그 토큰을 p에 리턴해주고 strtok(NULL,\ ,\);로 나누던 문자열을 계속해서 공백과 ,로 나누고 그 나눠진 토큰을 p에 리턴하겠다는 말입니다
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692144 | C언어와 리눅스에 대한 질문입니다. | 싴흐한세여니 | 2025-04-20 |
2692114 | 컨텍스트 스위칭하는데 걸리는 시간 측정.. | YourWay | 2025-04-19 |
2692086 | 간접참조 연산자, 증감연산자 질문이용! (2) | 블랙캣 | 2025-04-19 |
2692056 | 주석좀 달아주세요. 몇개적엇는데 몇개만달아주세요. (2) | DevilsTears | 2025-04-19 |
2691978 | 진수 쉽게 이해하는법... (3) | 지지않는 | 2025-04-18 |
2691949 | getchar() 한 문자를 입력받는 함수 질문 | 채꽃 | 2025-04-18 |
2691919 | 배열 정렬 및 합치기 질문입니다. | 사과 | 2025-04-18 |
2691845 | c언어왕초보 질문이 있습니다........ | 루나 | 2025-04-17 |
2691815 | void add(int num); 함수... (4) | 살랑살랑 | 2025-04-17 |
2691756 | 명령 프롬프트 스크롤바가 없어요 | 두메꽃 | 2025-04-16 |
2691725 | 자료구조에 관련해서 질문이 있어 글을 올립니다. | 누리알찬 | 2025-04-16 |
2691697 | if 문에서 구조체 배열에 저장되있던 문자열 검사하는 법 ? (2) | 민트맛사탕 | 2025-04-16 |
2691678 | C언어 함수 질문이요~!!! | 연보라 | 2025-04-15 |
2691650 | 반복문 | 돋가이 | 2025-04-15 |
2691618 | 링크드리스트 개념 질문이예요 (3) | 맨마루 | 2025-04-15 |
2691592 | 동적할당 이용 배열선언 질문입니다.ㅠㅠ (3) | 허리달 | 2025-04-15 |
2691542 | /=의 용도를 알려주세요 ㅠㅠ! (2) | 아라 | 2025-04-14 |
2691510 | sizeof 연산자 질문입니다 (2) | 종달 | 2025-04-14 |
2691483 | 파일 오픈시 에러 질문드립니다. (2) | 호습다 | 2025-04-14 |
2691450 | [visual c++ 툴]기초 질문 (3) | 해긴 | 2025-04-13 |