1

I have a double array a[1] which containing 2 doubles.

a[0]=36.78;    
a[1]=45.78;

Is it possible to transform them into 2 strings and put them in a string array?

thanks

Ramkrishna Sharma
  • 6,961
  • 3
  • 42
  • 51
charbel y
  • 47
  • 6

2 Answers2

2

You can do this to convert double to string:

double d = 123456.1234567899;
char s[50];

sprintf(s,"%f", d);
printf("%s\n", s);

And then create one string array like this

How to create array String

And finally you only need to bind this two things

Community
  • 1
  • 1
  • 1
    Use `snprintf` rather than `sprintf`. Avoid using functions that do not let you specify the size of the destination buffer. – dreamlax Feb 25 '16 at 08:27
1
  • declare a string array
  • convert each item to string within a for loop
  • and add each converted item to string array
Mucahid Uslu
  • 367
  • 3
  • 11