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

0

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Use snprintf rather than sprintf. Avoid using functions that do not let you specify the size of the destination buffer.
1
  • declare a string array
  • convert each item to string within a for loop
  • and add each converted item to string array

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.