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

  • SEARCH
  • Home
  • 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 8734401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:50:04+00:00 2026-06-13T09:50:04+00:00

I have the follwoing code: … printf(Started %d, pid); FILE * fh; fh =

  • 0

I have the follwoing code:

...
printf("Started %d", pid);
FILE * fh;
fh = fopen("run/source.pid", "wb");
fwrite(&pid, sizeof(int), 1, fh);
fclose(fh);

However the written pid file writes jargon, and not the integer, I though pid_t was just an int, I even tied doing sizeof(pid_t) for the second argument I get similar issues.

Any ideas? Thanks for the help in advance.

Thanks

  • 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-13T09:50:05+00:00Added an answer on June 13, 2026 at 9:50 am

    well I do not understand quite well the question (too little context), but the issue may be is that you are seeing the file in a text editor, terminal, etc..

    fwrite() writes raw data, for example, suppose you have a pid number, lets say 12, and you write that number using fwrite like this:

    fwrite(&pid, sizeof(int), 1, file);
    

    fwrite() will write a 32 bit integer into the file file, that is, depending in your processor type, a byte sequence like this: 00 00 00 12

    However

    fprintf() will write a byte sequence of : 49 50 (ASCII characters platform independent) visible among all terminals or text editors.

    Hope this helps.

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

Sidebar

Related Questions

I have following code written to run NSTimer . But the NSTimer selector is
I have the follwoing code: $(input:checkbox).live('click', function() { alert($(this).val()); }); True is shown if
I have the follwoing code and I would like to write it in a
I have the follwoing code from Richfaces 3.3 <h:inputText id=transamount value=#{myBean.amount}> <a4j:support event=onkeyup ajaxSingle=true
i have the follwoing code, but somes times i have the following Exception that
I have the follwoing code to save the image but it seems poor in
The follwoing code just returns the results: 0 0 in d:/result.txt. I have shown
I have a follwoing Jquery code, which create a Time Picker : <input class=time
I have the follwoing enum in my backend java code: public static enum CountryCodes
I have follwoing code @Html.DropDownList(optionsforuser, new SelectList(new[] { Option1, Option2 }), Select) Now i

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.