您好!
我有一个包含一些'.dat '格式的浮点数据的文件。 我知道要读取文件并将其存储在数组中的 C 代码、并且我正在使用相同的代码-但是、当我将程序加载到我的 MSP430FR5994 Launchpad 上时、程序会继续运行、但无法在控制台窗口中打印任何内容。 我以前曾读过一些有关 CCS 中'.dat '文件的格式如何不同的问题-特别是头 文件-但我无法找到最新 CCS 的确切文档、其中描述了如何重新构建文件以便可以读取 我也不知道这是否是我在文件中唯一需要做的更改。
我要附加'.ddat'文件和我用于读取相同内容的代码以供参考。 如果有人能将我重新引导到必要的链接、那将非常有帮助。 我将继续在论坛上搜索它、如果我发现它、将相应地更新此处的帖子。 谢谢!!
float spectrum[1024]; FILE *sampleFile; // Pointer to the sample data file int i = 0; // Index counter - used to keep track of which data point is being read in unsigned int coeff; // Determine which MFCC coefficient to compute float mfcc_result; // Holds the value of the computed coefficient // printf("Sample is: %d", 4); // Test statement to check where the code stops working memset(spectrum, 0, sizeof(spectrum)); // Initialize the spectrum sampleFile = fopen("sample.dat","r"); // Open the sample spectrum data // Read in the contents of the sample file while(!feof(sampleFile)) { fscanf(sampleFile, "%f", &spectrum[coeff++]); // %f tells fscanf to read a float } fclose(sampleFile); for(i=0;i<13;i++) { printf("%d, %f", i, spectrum[i]); }