1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Julli [10]
2 years ago
14

When this program is compiled and executed on an x86-64 Linux system, it prints the string 0x48\n and terminates normally, even

though function p2 never initializes variable main. Can you explain this?
Computers and Technology
1 answer:
Alexxandr [17]2 years ago
5 0

Answer:

I get 0x55 and this the linking address of the main function.

use this function to see changes:

/* bar6.c */

#include <stdio.h>

char main1;

void p2()

{

printf("0x%X\n", main1);

}

Output is probably 0x0

you can use your original bar6.c with updaated foo.c

char main;

int main() // error because main is already declared

{

  p2();

   //printf("Main address is 0x%x\n",main);

  return 0;

}

Will give u an error

again

int main()

{

  char ch = main;

  p2(); //some value

  printf("Main address is 0x%x\n",main); //some 8 digit number not what printed in p2()

  printf("Char value is 0x%x\n",ch); //last two digit of previous line output

  return 0;

}

So the pain in P2() gets the linking address of the main function and it is different from address of the function main.

Now char main (uninitialized) in another compilation unit fools the compiler by memory-mapping a function pointer on a char directly, without any conversion: that's undefined behavior. Try char main=12; you'll get a multiply defined symbol main...

Explanation:

You might be interested in
How many basic elements of QBASIC are there
Masteriza [31]
<h2>6</h2>

The elements used in Qbasic:

  • Character set.
  • Variables.
  • Constants.
  • Operator and Operands.
  • Expression.
  • Statements.
6 0
3 years ago
Write the steps for renaming an existing folder​
vekshin1

Answer:

Rename a file or folder

Explanation:

1.Right-click on the item and select Rename, or select the file and press F2 .

2.Type the new name and press Enter or click Rename.

8 0
3 years ago
Read 2 more answers
Where can I find answer key for electrician systems based on NEC 2017
lisov135 [29]

google or search through pvps

6 0
3 years ago
Which example task should a developer use a trigger rather than a workflow rule for?
Komok [63]

Answer:

A. To set the primary contact on an account record when it is saved

Explanation:

After updating a Contact and then you set the Primary checkbox, the contact becomes the primary contact and this then updates the reference in the Parent Account. Triggers are used for this purpose and not workflow rule. In this case there is only one contact at a time that is set as Primary Contacts, and in the case where an Account does not have any Contacts, the first contact that is created is made the primary and the trigger sets that value in reference.

6 0
3 years ago
An RSS feed allows an organization to publish new content on a website, blog or other platform and syndicate this to subscribers
yuradex [85]
Makes it easier for people to subscribe to your webpage without having to go and visit it.
3 0
3 years ago
Other questions:
  • During the processing stage what does the computer do
    12·1 answer
  • A(n application system is the master controller for all the activities that take place within a computer system. _______________
    15·1 answer
  • Identify the four basic categories of hardware in a personal computer system
    7·1 answer
  • Which of the following is not an example malicious code<br> A.Trojan horse B.worm C.virus D.spygear
    10·2 answers
  • The IP address is a _____ bit number.
    5·1 answer
  • Word processing software, spreadsheet software, database software, and presentation software are examples of what category of co
    12·1 answer
  • Compare and contrast the following network types: Personal Area Network (PAN) Local Area Network (LAN) Metropolitan Area Network
    14·1 answer
  • ZeroIt is a function that takes one argument and returns no value. The argument is a pointer to int. The function stores the val
    15·1 answer
  • A model is replica that?
    11·2 answers
  • The HTTP protocol operates at which layer?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!