200行の数字データ(double型で出力した数字)を1行ずつ読み込んでdouble型の配列に格納していく所で分からず止まっています。
数字を配列に格納したいので最終的にはdouble型の配列に入れたいのですが、型を合わせる方法が分からりませんでした。
格納された配列はぐちゃぐちゃ(数字ですらない)で目標とは違う値が格納されてしまいます。
プログラムの該当する部分だけ書きます。
#include <stdlib.h>
#include <iostream>
using namespace std;
int main(void)
{
double MAXDATASIZE = 20.0; //OMEGAxplot.txtの読み込む文字列の大きさ
char OMEGA0[200];
char OMEGA1[200];
char OMEGA2[200];
FILE *fp0, *fp1, *fp2;
fp0 = fopen("OMEGA0plot.txt","r");
fp1 = fopen("OMEGA1plot.txt","r");
fp2 = fopen("OMEGA2plot.txt","r");
int i;
for(i=0;i<200;i++)
{
fgets(OMEGA0,MAXDATASIZE,fp0);
omega0[i]=atof(OMEGA0); /*文字列として読んだものを数値化*/
}
for(i=0;i<200;i++)
{
fgets(OMEGA1,MAXDATASIZE,fp1);
omega1[i] = atof(OMEGA1);
}
for(i=0;i<200;i++)
{
fgets(OMEGA2,MAXDATASIZE,fp2);
omega2[i] = atof(OMEGA2);
}
fclose(fp0);
fclose(fp1);
fclose(fp2);
return 0;
}
1>------ ビルド開始: プロジェクト: 20120111-3, 構成: Debug Win32 ------
1>2012/01/11 21:25:08 にビルドを開始しました。
1>InitializeBuildStatus:
1> "Debug\20120111-3.unsuccessfulbuild" のタッチ タスクを実行しています。
1>ClCompile:
1> test.cpp
1>e:\opengl\20120111-3\20120111-3\test.cpp(15): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(234) : 'fopen' の宣言を確認してください。
1>e:\opengl\20120111-3\20120111-3\test.cpp(16): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(234) : 'fopen' の宣言を確認してください。
1>e:\opengl\20120111-3\20120111-3\test.cpp(17): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(234) : 'fopen' の宣言を確認してください。
1>e:\opengl\20120111-3\20120111-3\test.cpp(22): warning C4244: '引数' : 'double' から 'int' への変換です。データが失われる可能性があります。
1>e:\opengl\20120111-3\20120111-3\test.cpp(23): warning C4244: '=' : 'double' から 'char' への変換です。データが失われる可能性があります。
1>e:\opengl\20120111-3\20120111-3\test.cpp(28): warning C4244: '引数' : 'double' から 'int' への変換です。データが失われる可能性があります。
1>e:\opengl\20120111-3\20120111-3\test.cpp(29): warning C4244: '=' : 'double' から 'char' への変換です。データが失われる可能性があります。
1>e:\opengl\20120111-3\20120111-3\test.cpp(33): warning C4244: '引数' : 'double' から 'int' への変換です。データが失われる可能性があります。
1>e:\opengl\20120111-3\20120111-3\test.cpp(34): warning C4244: '=' : 'double' から 'char' への変換です。データが失われる可能性があります。
1>ManifestResourceCompile:
1> すべての出力が最新のものです。
1>Manifest:
1> すべての出力が最新のものです。
1>LinkEmbedManifest:
1> すべての出力が最新のものです。
1> 20120111-3.vcxproj -> E:\OpenGL\20120111-3\Debug\20120111-3.exe
1>FinalizeBuildStatus:
1> ファイル "Debug\20120111-3.unsuccessfulbuild" を削除しています。
1> "Debug\20120111-3.lastbuildstate" のタッチ タスクを実行しています。
1>
1>ビルドに成功しました。
1>
1>経過時間 00:00:00.85
========== ビルド: 1 正常終了、0 失敗、0 更新不要、0 スキップ ==========