20130917【C言語】scanfでスペースを含んだ文字列を読み込む

お題

scanfでスペースを含んだ文字列を読み込む

 

ソース

#include <stdio.h>

int main(void)
{
 char str[80];
 
 printf("アルファベット文字とスペースを入力してください: ");
 scanf("%[a-zA-Z ]", str);
 printf("%s\n", str);

 return 0;
}

 

実行結果

f:id:mocomei:20130917082623p:plain