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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:00:10+00:00 2026-05-12T10:00:10+00:00

I am new to C and reviewing some source code. But I am not

  • 0

I am new to C and reviewing some source code. But I am not sure what is happening with this code snippet.

I really don’t think it is doing anything, as in the debugging the output seems to be the same for tempstr.

This is what I think, correct if I am wrong.
*(tempstr + strlen(line)) is adding the length of line to tempstr and dereferencing and assigning the 0x0 converted to a char?

char line[128], tempstr[128]

strcpy(line, "AUTO_ANSWER_CALL = 1");
strcpy(tempstr,line);
*(tempstr + strlen(line)) = (char) 0x0; // Confusing part
  • 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-05-12T10:00:10+00:00Added an answer on May 12, 2026 at 10:00 am

    This is a pointer value:

    tempstr
    

    This is another pointer value (which points to 5 elements beyond the tempstr pointer value):

    tempstr + 5
    

    This is an integer:

    strlen(line)
    

    Therefore, this is a pointer value (which points to strlen(line) elements beyond the tempstr pointer value):

    tempstr + strlen(line)
    

    And this is dereferencing that pointer:

    *(tempstr + strlen(line))
    

    This is what I think, correct if I am wrong. *(tempstr + strlen(line)) is adding the length of line to tempstr and dereferencing and assigning the 0x0 converted to a char?

    It’s ensuring that the character at index 20 of tempstr, immediately beyond the “AUTO_ANSWER_CALL = 1” characters, is null: i.e. it’s ensuring that the string is null-terminated.

    That string already is null-terminated, by the way (so that last statement is redundent): because strcpy copies the string including the implicit null-termination character.


    Isn’t easier just to do the following tempstr[sizeof(tempstr)-1] = ‘\0’; this is much easier to understand.

    These aren’t the same thing: strlen(line) equals 20, but sizeof(tempstr) equals 128.


    would this work: tempstr[strlen(tempstr)] = ‘\0’

    That’s exactly the same things as:

    *(tempstr + strlen(tempstr)) = '\0'
    

    Just a different way of writing it.

    However, if tempstr is NOT a null terminated string, the length would be 128 as well.

    If tempstr is NOT a null terminated string then strlen(tempstr) is undefined (‘undefined’ means that it’s meaningless and dangerous, a bug, and shouldn’t be used): the strlen function isn’t valid except when it’s used on a string that’s already null-terminated.

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

Sidebar

Ask A Question

Stats

  • Questions 287k
  • Answers 287k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Such query requires one SELECT less: RETURN ISNULL((SELECT 1 WHERE… May 13, 2026 at 5:12 pm
  • Editorial Team
    Editorial Team added an answer I find that I'm using LINQ just about any time… May 13, 2026 at 5:11 pm
  • Editorial Team
    Editorial Team added an answer A vector has 1 dimension while a data frame has… May 13, 2026 at 5:11 pm

Related Questions

I don't intend this to be subjective, but if the answers can be seasoned
I am new to C# and am doing some work in an existing application.
I am new to C and i have this question. why does the following
I am new to C# and .NET programming. I want to design an application

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.