π•ƒπ•¦π•„π•šπ•£

γ€ŒβŒ¨οΈα΄„s」STUDY/C

[C][header][stdio.h] scanf

by λ£¨λ°€π•ƒπ•¦π•„π•šπ•£2023. 1. 29.
728x90
λ°˜μ‘ν˜•

scanf

ν•¨μˆ˜ μ›ν˜•
#include <stdio.h>  // C++ 의 경우<cstdio>
int scanf(const char* format, ...);
곡백을 ν¬ν•¨ν•˜μ—¬ λ¬Έμžμ—΄λ‘œ μž…λ ₯λ°›λŠ” 방법
#include <stdio.h>

int main(void){
  char arr[100]; 
  
  scanf("%[^\n]", arr); // "%[^\n]"은 μ—”ν„°κ°€ λ‚˜μ˜¬λ•ŒκΉŒμ§€ λ¬Έμžμ—΄λ‘œ λ°›λŠ”λ‹€λŠ” 말이닀( 곡백도 포함 )
  
  return 0;
}

"%[^\n]"은 μ—”ν„°κ°€ λ‚˜μ˜¬λ•ŒκΉŒμ§€ λ¬Έμžμ—΄λ‘œ λ°›λŠ”λ‹€λŠ” λœ»μ΄λ‹€. (곡백을 ν¬ν•¨ν•œλ‹€ )

 

728x90
λ°˜μ‘ν˜•

'γ€ŒβŒ¨οΈα΄„s」STUDY > C' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

[C][Macro] min max  (0) 2023.02.21
[C][header][stdio.h] printf  (0) 2023.01.31
[C][header][stdio.h] fgets  (0) 2023.01.23
[C][header][limits.h]  (0) 2023.01.23