answer.
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
A communication pattern in which the parties slowly reduce their dependence on one another, withdraw, and become less invested i
zepelin [54]

Answer:

The correct answer to the following question is option A. an avoidance spiral.

Explanation:

An avoidance spiral is a spiral in which parties avoid the conflicts at all cost in which leads to reducing the influence, dependence, etc. This spiral can also be destructive.

In other words, it is the only spiral in parties slowly reduces their dependence and the influence on the one and another.

7 0
2 years ago
Steps in creating a folder
enyata [817]
Right click computer screen and press new folder?
or add paper to rings in the physical folder<span />
8 0
2 years ago
Which of the following is a benefit, as well as a risk, associated with client/server networks?
KATRIN_1 [288]
C would be the correct answer to this question
6 0
2 years ago
A cell reference that has only one $ is referred to as a(n) ____ cell reference. alternative mixed relative absolute
Allushta [10]
An absolute cell reference.
4 0
2 years ago
Sam’s password is known to be formed of 3 decimal digits (0-9) in a given order. Karren and Larry are attempting to determine Sa
prohojiy [21]

Answer:

100

Explanation:

7 0
2 years ago
Read 2 more answers
Other questions:
  • Donna often travels around the world. When she travels, she needs to access her emails from different locations. However, to kee
    6·2 answers
  • A new company starts up but does not have a lot of revenue for the first year. Installing anti-virus software for all the compan
    11·1 answer
  • Give at least one example computer application for which a connection-oriented service is appropriate and at least one example c
    12·1 answer
  • Many organizations keep copyrighted information on their intranets, which is one reason usernames and passwords are required. Tr
    13·1 answer
  • Consider the following code: x = 17 y = 5 print (x % y) What is output?
    10·1 answer
  • Assume that a kernel is launched with 1000 thread blocks each of which has 512 threads. If a variable is declared as a shared me
    6·1 answer
  • Our company is only interested in purchasing a software upgrade if it leads to faster connectivity and data sharing. The old sof
    7·1 answer
  • Ken Olson, president of Digital Equipment Corp. in the late 1970's, Thomas J. Watson, chairman of IBM in the early 1940's, and T
    6·1 answer
  • Which OS function does a CLI fulfill? A User interface B Running applications C Hardware interface D Booting
    8·1 answer
  • Write code that determines the number of full days represented by the number of hours stored in the variable hours and stores th
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!