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

The Archive Base Latest Questions

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

I came across a programming question of which I knew only a part of

  • 0

I came across a programming question of which I knew only a part of the answer.

int f( char *p )
{
int n = 0 ;
while ( *p != 0 )
n = 10*n + *p++ - '0' ;
return n ;
}

This is what I think the program is doing.
p is a pointer and the while loop is DE-refrencing the values of the pointer until it equals 0. However I don’t understand the n assignment line, what is ‘0’ doing? I am assuming the value of p is initially negative, that is the only way it will reach 0 after the increment.

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

    You are confusing the number zero (none, nothing) with the character 0 (a circle, possibly with a slash through it). Notice that zero is in tick marks, so it’s the character “0”, not the number zero.

    ‘0’ – ‘0’ = 0
    ‘1’ – ‘0’ = 1
    ‘2’ – ‘0’ = 2
    …

    So by subtracting the character zero from a digit, you get the number that corresponds to that digit.

    So, say you have this sequence of digits: ‘4’, ‘2’, ‘1’. How do you get the number four-hundred and twenty-one from that? You turn the ‘4’ into four. Then you multiply by ten. Now you have fourty. Convert the ‘2’ into two and add it. Now you have fourty-two. Multiply by ten. Convert the ‘1’ into one, and add, now you have four hundred and twenty one.

    That’s how you convert a sequence of digits into a number.

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

Sidebar

Related Questions

While studying for a Functional Programming exam, I came across the following question from
I'm writing a programming language, and when I came across this question , my
I came across a good question while preparing for some programming interviews. Given a
While seeing a programming interview site, I came across code which swap adjacent elements
While studying for a Functional Programming exam, I came across the following questions from
Recently I came across this video on Programming Paradigms and the prof. used terms
I'm new to C programming and I just came across this program and got
I came across a piece of code which looks like this: jQuery(function($) { $('#saySomething').click(function()
While reading SICP I came across logic programming chapter 4.4. Then I started looking
I just came across this question about initializing local variables. Many of the answers

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.