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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:16:37+00:00 2026-06-12T13:16:37+00:00

This code works fine after commenting statement one. Statement two gives some garbage value

  • 0

This code works fine after commenting statement one. Statement two gives some garbage value but at least it runs. I’m not getting how does the printf in argument gives a value if it’s not called as a function?

#include<stdio.h>

int main()
{
    int printf = 123;    // statement one
    printf ("%d", printf); // statement two  
    return 0;
}
  • 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-12T13:16:38+00:00Added an answer on June 12, 2026 at 1:16 pm

    A function name without parentheses doesn’t return a value – it evaluates to the address of the function (i. e. it is a function pointer of type size_t (*)(const char *, ...)). Essentially, this is the address where the CPU will jump among the instructions whenever it encounters a call to printf().

    By the way, if I recall correctly, assigning to a function’s name is undefined behavior, so is printing a pointer using the %d format specifier – you should use

    printf("%p", (void *)printf);
    

    Also, you can declare function pointers, assign them the address of another function and call them just fine:

    size_t (*my_printf)(const char *, ...) = printf;
    my_printf("This actually called printf!\n");
    
    printf("my_printf: %p\n", (void *)my_printf);
    printf("original printf: %p\n", (void *)printf);
    

    The last two statements print the same address.

    Edit: Strictly speaking, even the above “solution” is nonstandard as the Standard doesn’t guarantee that function pointers can be cast to data pointer types. That means basically that there’s no way for print the address of a function, however, on most systems, casting to void * apparently works.

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

Sidebar

Related Questions

This code works fine, but I'll want to handle exception if any thing goes
This code works fine to find an available room within certain date, but it
This code works fine in C#: Expression.Lambda(LambdaBody); But none of the methods for building
Please i need help, this code below works fine on my localhost, php5.3+ but
This code works fine in IE8/7 and Firefox... But in Google Chrome i got
This code works fine in Chrome. However, in Firefox, when it hits the GMxhr
this code works fine until I start scrolling: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
The code below is creating a server to communicate with clients.This code works fine
web page : http://sideradesign.com/eco-art/gallery/ This code works fine in all brwosers except IE8 (haven't
I'm using core motion in my app. This code works fine: motionManager = [[CMMotionManager

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.