[問題]C++ reading double precision data

看板Programming作者 (new)時間17年前 (2008/03/24 03:52), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
各位高手!! 請問一下!!我在從file讀double precision數值時 發現有個這樣的問題!! //"test.txt"內容 //-5.000000 -7.56597e-200 //-4.999900 -7.5678e-006 //-4.999800 -7.56963e-006 //cout內容 //-5.000000 0.000000e+000 ^^^^^^^^^^^^^^^^^^^^ //-4.999900 -7.5678e-006 //-4.999800 -7.56963e-006 我該如何解決呢???謝謝 //以下是程式碼!! ////////////////////////////////////////////////// #include<iostream> #include<math.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> using namespace std; main() { int i,col; float value; FILE *fp; fp=fopen("test.txt","r"); col=2; i=1; while (fscanf(fp, "%f%*c", &value) != EOF) { printf("%e\t",value); if(i%col==0) {cout<<"\n";i=0;} i++; } fclose(fp); getch(); return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.203.119.154 rabbit1983:轉錄至看板 C_and_CPP 03/24 04:05
文章代碼(AID): #17vhKBef (Programming)
文章代碼(AID): #17vhKBef (Programming)