Quick actions

cmd+k|ctrl+k

Navigation

Languages

Untitled

Snippet info

Language

C

Visibility

public

Author

mori

Created

2020-01-09T01:16:22Z

Updated

2020-01-09T01:16:22Z

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h> // malloc, free 함수가 선언된 헤더 파일
#include <string.h>

int main()
{

char* ptr = malloc(sizeof(char) * 1000);

scanf("%[^\n]s", ptr);


int count = 0;

while (ptr != NULL)

{

if (ptr == " ")  // 공백이라면

{

count += 1;

ptr += 1;

}

ptr += 1;

}


printf("%d\n", count);


free(ptr);

return 0;

}
INFO