Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8548677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:32:58+00:00 2026-06-11T13:32:58+00:00

Given double temp = 6.5; how could I pass it to the UNIX write()

  • 0

Given double temp = 6.5; how could I pass it to the UNIX write() system call:

write(fd[1], (WTF?), 100)

  1. fd[1] is a file descriptor.
  2. 100 is a fixed buffer size to handle large number values, just in case.

What do I put it in the middle? I’ve tried itoa, &temp, *temp, (char) temp, and a few other ways by googling my way to different solutions, but with no luck so far. Honestly I don’t even know what type is const void *. I just know it will stop complaining if I pass a string directly such as “Hello World” to the 2nd argument.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:32:59+00:00Added an answer on June 11, 2026 at 1:32 pm

    The second parameter to write is a pointer to some location in memory, and the third parameter is the number of bytes from that location in memory that you want to write to the file. So your code would be:

    double temp = 6.5;
    write(fd[1], &temp, sizeof(temp));
    

    I’m not sure if this is exactly what you want, though. To be clear, this will write the binary representation of your double to the file. On most platforms, that will be the following series of bytes (represented here in hexadecimal):

    00 00 00 00 00 00 26 64

    If this is supposed to be a text file, then you’ll want to convert your number to a string first.

    double temp = 6.5;
    char buffer[20];
    sprintf(buffer, "%g", temp);
    write(fd[1], buffer, strlen(buffer));
    

    This would write “6.5” to your file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

given the following function signature: void readFileData(FILE* fp, double inputMatrix[][], int parameters[]) this doesn't
How can I give double space between every three lines in a text file
Here's what I do: double x = 7.0; System.out.printf(%.2f, x); Eclipse gives me this
Given the following declaration: double x; What is the value of x ? Is
i have a really big array of numbers with double precision...i tried to write
Does .NET have a built-in method to calculate the ULP of a given double
I want with a given double number to return its size (known as |number|,
Given a double value like 1.00500000274996E-8, how do I convert it to it's non
Given double x , and assuming that it lies in [0,1] . Assume for
From a given double I want to get the next highest number according to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.