printf and cout question

hi,

i have :

1
2
for(int i=0;i<size;i++)
         printf("arr[%3d] = %15.7le\n", i, arr[i]);


which return numbers like the following :

1.0000126e+00


how can i have the same result using cout ??

Thanks !
the arr() is double.

when i type it using printf i receive for example
1.0000126e+00
but with cout i receive
1
.. any idea how to solve this ?
1
2
for(int i=0;i<size;i++)
	std::cout << "arr[" << std::setw(3) << i << "] = " << std::scientific << std::setw(15) << std::setprecision(7) << arr[i] << "\n";
Last edited on
Topic archived. No new replies allowed.