next up previous contents
Next: gettimer Up: リファレンスマニュアル Previous: getenv

  
gets

【目的】
gets - 標準入力から文字列を読み込む
【形式】
str = gets()       str = gets(len)
   String str;        String str;
                      Integer len;
【詳細】
gets()は,標準入力から文字列を 1 行(改行コードを含まない) あるいは 1023 個の文字を読み込み,文字列を返す。リターンキー のみ入力すると,長さゼロの文字列を返す。 gets(len) は,ファイルから文字列を 1 行(改行コードを含まない) あるいは len 個の文字を読み込む。
【例題】
標準入力からリターンのみが入力されるまで,データを読み込み, 標準出力に出力する。
while (length(str = gets())) {
    printf("%s\n", str);
}
【参照】
fgets(2.69), fscanf(2.82)


Masanobu KOGA 平成11年10月2日