秋田大学ICPC対策室@wiki

標準入出力(stdio.h)

最終更新:

akitaicpc

- view
だれでも歓迎! 編集

標準入出力 <stdio.h>


書式付きデータを標準出力に書き込む

printf(const char *Format, ... )
引数 Format:出力する文字列(書式付き)
     ...:出力する値のリスト
戻り値:出力した文字数(バイト数)
+ プログラム例
#include <stdio.h>

int main(){
	int    a = 5;
	double b = 0.3;
	char   c = 'H';
	char d[80] = "ello";
	printf("%d %f %c %s \n", a , b , c , d);

	return 0;
}
実行結果
5 0.300000 H ello


書式付きデータを標準入力から読みだす

scanf(const char *Format, ... )
引数 Format:読みだすデータの書式
+ プログラム例
#include <stdio.h>

int main(){
	int a;

	printf("数値を入力してください:");
	scanf("%d" , &a);
	printf("入力した値は%dです\n", a);

	return 0;
}



標準入力から1行の文字列を読みだす

gets(char *buffer)
引数 buffer:
戻り値:成功したときはバッファをさすポインタ
       ファイルの終わり、またはエラーのときNULL
+ プログラム例
誰か編集して...







...

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

目安箱バナー