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]
1 year 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]1 year 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
Write two methods: encrypt and decrypt. encrypt should #take as input a string, and return an encrypted version #of it according
Harman [31]

Answer:

The code is given below with appropriate comments

Explanation:

CIPHER = (("D", "A", "V", "I", "O"),

         ("Y", "N", "E", "R", "B"),

         ("C", "F", "G", "H", "K"),

         ("L", "M", "P", "Q", "S"),

         ("T", "U", "W", "X", "Z"))

# Add your code here!

def encrypt(plaintext):

   theList = []

   for char in plaintext:

       if char.isalpha():

           char = char.upper()

           if char == "J":

               char = "I"

           theList.append(char)

   if len(theList) % 2 == 1:

       theList.append("X")

   for i in range(0, len(theList), 2):

       if theList[i] == theList[i + 1]:

           theList[i + 1] = "X"

       findex = [-1, -1]

       sindex = [-1, -1]

       for j in range(len(CIPHER)):

           for k in range(len(CIPHER)):

               if theList[i] == CIPHER[j][k]:

                   findex = [j, k]

               if theList[i + 1] == CIPHER[j][k]:

                   sindex = [j, k]

       # same row

       if (findex[0] == sindex[0]):

           findex[1] += 1

           sindex[1] += 1

           if findex[1] == 5:

               findex[1] = 0

           if sindex[1] == 5:

               sindex[1] = 0

           theList[i] = CIPHER[findex[0]][findex[1]]

           theList[i + 1] = CIPHER[sindex[0]][sindex[1]]

       # same column

       elif (findex[1] == sindex[1]):

           findex[0] += 1

           sindex[0] += 1

           if findex[0] == 5:

               findex[0] = 0

           if sindex[0] == 5:

               sindex[0] = 0

           theList[i] = CIPHER[findex[0]][findex[1]]

           theList[i + 1] = CIPHER[sindex[0]][sindex[1]]

       else:

           theList[i] = CIPHER[findex[0]][sindex[1]]

           theList[i + 1] = CIPHER[sindex[0]][findex[1]]

   return "".join(theList)

def decrypt(ciphertext):

   theString = ""

   findex = [-1, -1]

   sindex = [-1, -1]

   for i in range(0, len(ciphertext), 2):

       for j in range(len(CIPHER)):

           for k in range(len(CIPHER)):

               if ciphertext[i] == CIPHER[j][k]:

                   findex = [j, k]

               if ciphertext[i + 1] == CIPHER[j][k]:

                   sindex = [j, k]

       if (findex[0] == sindex[0]):

           findex[1] -= 1

           sindex[1] -= 1

           if findex[1] == -1:

               findex[1] = 4

           if sindex[1] == -1:

               sindex[1] = 4

           theString += CIPHER[findex[0]][findex[1]]

           theString += CIPHER[sindex[0]][sindex[1]]

       # same column

       elif (findex[1] == sindex[1]):

           findex[0] -= 1

           sindex[0] -= 1

           if findex[0] == -1:

               findex[0] = 4

           if sindex[0] == -1:

               sindex[0] = 4

           theString += CIPHER[findex[0]][findex[1]]

           theString += CIPHER[sindex[0]][sindex[1]]

       else:

           theString += CIPHER[findex[0]][sindex[1]]

           theString += CIPHER[sindex[0]][findex[1]]

   return theString

# Below are some lines of code that will test your function.

# You can change the value of the variable(s) to test your

# function with different inputs.

#

# If your function works correctly, this will originally

# print: QLGRQTVZIBTYQZ, then PSHELXOWORLDSX

print(encrypt("PS. Hello, worlds"))

print(decrypt("QLGRQTVZIBTYQZ"))

5 0
1 year ago
Consider an improved version of the Vigen ere cipher, where instead of using multiple shift ciphers, multiple mono-alphabetic su
anzhelika [568]

Answer:

Kasiski’s method for determining 't' works for Vigenère cipher as well. The only difference is therefore in the second stage of the attack. In the second stage, one needs to build a frequency table for each of the 't' keys, and carry out an attack like on the mono-alphabetic cipher. Given a long enough plaintext, this will work successfully.

Explanation:

Kasiski method is a method of attacking polyalphabetic substitution ciphers such as Vigenère cipher. It is also called Kasiski test or Kasiski examination.

The method involve finding the length of the keyword and then dividing the message into that many simple substitution cryptograms. Frequency analysis could then be used to solve the resulting simple substitution.

6 0
2 years ago
Nathan wants to make the quotation stand out further. Which order of steps does he need to follow to do this task?
Alina [70]

Answer:

B.

Explanation:

Go to the Borders and Shading option, click the Shading tab, and click the color under the Fill option.

5 0
2 years ago
Read 2 more answers
Which of the following should be filed immediately after Wakefield, Donald?
Eva8 [605]
This is the order in which it should be filed.

Wakefield, Cyndi
Wakefield, Donald  
Wakefield, Drew  ⇒ this is the answer. Since both have Ds, we evaluate O and                                     R. O comes first before R.
Wakefield, Edgar
Wheton, John
8 0
2 years ago
#In Pokemon Go, a Pokemon is defined by several different #parameters. For simplicity in this problem, we'll say that #every Pok
Semenov [28]

Answer:

YUP

Explanation:

5 0
1 year ago
Read 2 more answers
Other questions:
  • What is an icon or animation used to represent a participant in an internet chat referred as?
    7·2 answers
  • WILL MARK BRAINLIEST HELP
    8·2 answers
  • Peter accumulated many photos from his visit to Wisconsin. He wants to upload these photos to a social networking site. Which fi
    12·1 answer
  • QUESTION 9 of 10: Bob charged $200 for a plane ticket last month. When he received his statement, he saw that he could pay the m
    12·2 answers
  • Given an array of ints named x and an int variable named total that has already been declared, write some code that places the s
    6·1 answer
  • There are two methods of enforcing the rule that only one device can transmit. In the centralized method, one station is in cont
    5·1 answer
  • Identify the articulation site that allows us to nod our head ""yes"".
    13·1 answer
  • Garrett wants to search through a csv file to find all rows that have either the name John or Bob in them and display them out t
    9·1 answer
  • A news channel runs a two-minute story on phishing scams. The report features the testimonies of a phishing victim and a compute
    7·1 answer
  • Checkpoint 10.43 Write an interface named Nameable that specifies the following methods: _______{ public void setName(String n)
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!