파일 입력 - scanf()와 fgets()
본 자료는 2페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
해당 자료는 2페이지 까지만 미리보기를 제공합니다.
2페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

파일 입력 - scanf()와 fgets()에 대한 보고서 자료입니다.

목차

1.scanf()와 fgets() 개념

2.scanf()와 fgets() 공통점

3.scanf()와 fgets() 다른점

4.fgets()와 gets() 비교

5.fgets()의 gets()로 쓰기위한 조건

본문내용

정의
scanf( const char *format, arg1, arg2, … ) – 숫자를 받아 들일 때
fgets(char *buffer, int n, FILE *fp) – 문자열을 받아 들일 때

#include //malloc 인클루드
#include

main()
{
char *name;

name = (char *)malloc(sizeof(char) * 20);
// (void *)malloc(sizeof(void)*확보하고자하는바이트수)

printf(“Input your name : ");
scanf("%s", name);
putchar(name);
}

#include //malloc 인클루드
#include
main()
{
char *name;
char *name2;
char *name3;

name = (char *)malloc(sizeof(char) * 10);
name2 = (char *)malloc(sizeof(char) * 10);
name3 = (char *)malloc(sizeof(char) * 10);

printf("Input your name : ");
scanf("%s %s %s", name, name2, name3);
printf("%s %s %s\n",name, name2, name3);
}

문자열 입력 받을때
gets(char *buffer) – 표준 입력에서 문자열을 읽어 들이는 함수
fgets(char *buffer, int n, FILE *fp) – 파일에서 문자열을 읽어 들이는 함수
#include
#include

main()
{
char *name;

name = (char *)malloc(sizeof(char) * 10);

printf("Input your name : ");
gets(name);
puts(name);
}

키워드

c언어,   scanf,   fgets,   gets,   strcmp,   strlen,   오버플로우,   malloc
  • 가격1,000
  • 페이지수7페이지
  • 등록일2004.07.06
  • 저작시기2004.07
  • 파일형식파워포인트(ppt)
  • 자료번호#259593
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니