특정 문자열에서 포맷대로 데이터를 읽어옴.

 

저장 변수가 문자열인 경우 크기값도 이어서 넣어야함.

%s 뒤에는 띄어쓰기 꼭 있어야 하는것 같음.

    char tokenstring[30] = "15 :12 :14";
    char string[30] = "ABC -Z";
    char  ws[81];
    char  wc;
    int i;
    float fp;
    char  sss[81];
    char  c;

    sscanf_s(tokenstring, "%s : %d : %f", sss, (unsigned int)sizeof(sss), &i, &fp);
    sscanf_s(string, "%s - %c", ws, (unsigned int)sizeof(ws), &wc);

sscanf_s의 포멧에 구분자만 잘 맞추면 띄어쓰기 있던 없던 괜찮은 듯.

'유용한 기술' 카테고리의 다른 글

[algorithm] transform & inserter  (0) 2024.05.14
(custom sort) Compare 작성  (0) 2024.05.11
c++ algorithm [count, count_if]  (0) 2023.10.11
벡터, 각도, 삼각함수  (0) 2023.09.07
UML  (0) 2023.08.30

+ Recent posts