Commits

Takayuki KONDO committed a52c211

c: csv サンプルコード追加

Comments (0)

Files changed (1)

+#include <stdio.h>
+
+int main()
+{
+	FILE *fp;
+	char *fname = "comma.csv";
+
+	char  *s[] = {"test01", "test02", "test03"};
+	int    n[] = {10, 20, 30};
+	double d[] = {1.0, 2.0, 3.0};
+	int i;
+
+	fp = fopen( fname, "w" );
+	if( fp == NULL ){
+		fprintf( stderr, "%s open error\n", fname);
+		return -1;
+	}
+
+	for (i=0; i<3; i++)
+	{
+		fprintf( fp, "%s,%d,%d,%f,%f\n", s[i], n[i], n[i]+1, d[i], d[i]+0.1 );
+	}
+	fclose( fp );
+
+	printf( "%s created.\n", fname );
+	return 0;
+}