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 8621685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:52:27+00:00 2026-06-12T06:52:27+00:00

I am using fprintf to append a string to a document, here is the

  • 0

I am using fprintf to append a string to a document, here is the line I have a question about:

fprintf(win, bff[i - 2] != '\n' && bff[i - 2] != '\r' ? "\nmultiscreen=1" : "multiscreen=1");

The code works, it appends multiscreen=1 to the next available line in the file.

But if I understand correctly wouldn’t it NOT be adding a NULL character to the end of multiscreen=1?
Does this even matter since I’m writing it to a file and the trailing NULL in a string is a C thing?

Or would it be more correct to use fputs instead of fprintf?

  • 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-12T06:52:29+00:00Added an answer on June 12, 2026 at 6:52 am

    String literals automatically have a 0 as the last character in them. So you don’t need to add one yourself.

    The NUL terminator is only for fprintf (or whatever string function you are using) to know when to stop writing characters from the pointer; no NUL is actually ever written to the file.

    And yes, I would recommend using fputs instead of fprintf since you’re not using any of the formatting facilities of fprintf, unless you use pmg’s suggestion in the comments to your question which does use formatting sequences.

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

Sidebar

Related Questions

I have a C function that prints to stdout using fprintf , and I'm
As of now I'm using below line to print with out dot's fprintf( stdout,
I'm using Visual Studio 2008 Express, and I have this logging code: fprintf(fp,%s %s
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using import datetime in python, is it possible to take a formatted time/date string
I have code using boost to list directory contents, iterate through each file, and
I'm using a fprintf function to print to a new file I'm using the
I have succesfully using dyld -macosx- to interpose standard C functions to a third
Using trylock: FILE *fp; pthread_mutex_t demoMutex; void * printHello (void* threadId) { pthread_mutex_trylock (&demoMutex);
I'm using the following program in C to filter a log file with about

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.