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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:40:56+00:00 2026-06-10T10:40:56+00:00

Possible Duplicate: How does “while(*s++ = *t++)” work? I had the following question during

  • 0

Possible Duplicate:
How does “while(*s++ = *t++)” work?

I had the following question during an interview. Can someone please explain it to me?

void question( char *s, char *t)
{
  while (*s++ = *t++);
}
  • 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-10T10:40:58+00:00Added an answer on June 10, 2026 at 10:40 am

    Copies the string, pointer by t to the memory, pointed by s.


    operator= will return the assigned value. t is supposed to point to a NULL-terminated string and s should point to memory, large enough to store that string.

    So, the while loop will stop when \0 is hit, which is the end of the string, pointed by t. During this while loop, all chars (different from \0) in t will be copied into s.


    Expanded a little, it’s the same as:

    while( *t != '\0' ) // while the current char is not NULL
    {
        *s = *t; // copy it into s
        ++s; // increment s, to point to the next byte
        ++t; // increment t, to point to the next char, that will be copied
    }
    *s = *t; // copy the last char of t - the '\0'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How exactly does <script defer=“defer”> work? Can anybody explain me how defer
Possible Duplicate: g++ “is not a type” error The following does not compile: 1
Possible Duplicate: What does “>” mean in CSS rules? CSS has the following two
Possible Duplicate: How does this “size of array” template function work? Is there any
Possible Duplicate: In Ruby what does “=>” mean and how does it work? Just
Possible Duplicate: Why have “while(1);” in XmlHttpRequest response? What does while(1) in Gmail do
Possible Duplicate: Question on this JavaScript Syntax (“What Does This Do?”) in this article
Possible Duplicate: How does the vim “write with sudo” trick work? Many times I
Possible Duplicate: Why does “abcd”.StartsWith(“”) return true? The following simple Java code just uses
Possible Duplicate: What does “(void) new” mean in C++? I'm not familiar with C++

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.