Question

In: Computer Science

Modify the following code to use 'envp' instead of 'environ'. Be sure that you understand how...

Modify the following code to use 'envp' instead of 'environ'. Be sure that you understand how the code works. Provide liberal comments to explain what your pointer arithmetic is computing. Also, answer the following questions and explain your answers:

i) WHERE in process memory is it most likely that each of the values exist at run time?

ii) WHERE in process memory is it most likely the actual strings containing environment variables are stored?

#include
#include

extern char **environ; // look into what “extern” means when applied to
// a C global variable :)


int main(int argc, char **argv)
{ char **env_variable_ptr;

env_variable_ptr = environ;

while (*env_variable_ptr != NULL)
{ printf("%s\n", *env_variable_ptr);
env_variable_ptr++;
}

printf("\n");

}

Solutions

Expert Solution

1) The programming languages like C and C++, its static and dynamic memory allocation. All memory waas allocated during compile time.

C/C++ code to mashine output an executable file allocated in a compile file, memory always allocated in the RAM with the virtual memory.

The memory allocation at run/ compile-time resolves at the inside process of memory map

consider a global array variable.

int array [100];

Its compile-time the size of the array and the size of an int, its static storage global variable is allocated in static memory area of process memory.

Value initialized static storage.

int array[] = { 1,2,3,4,5 }

2) It consider memory segment data,heap,stack,and code, is allocated space by globle variable ,static variable get storage in memory.

1.global variable .. // data

2. static variables... // data

3. constant data type...// Its code and /or data, as string constant itself can be stored in the data sagment.

4. local variables... // stack

5. pointers... // ie *arr,int // It has heap data or stack,as declare a global or static pointer.

6. dynamically allocation ....// Its space using stack heap ( malloc,calloc,or realloc).


Related Solutions

Modify the classes so that it accepts integers instead of characters. (If you understand the concept...
Modify the classes so that it accepts integers instead of characters. (If you understand the concept of generic classes, convert the Node and Linked List classes to a generic so that they can be instantiated with either integers or characters) JAVA Code class aNode { char data; aNode next; aNode(char mydata) { // Constructor data = mydata; next = null; } }; //----------------------------------------------------- class linkedList { aNode head; // Head of the linked list int size; linkedList() { // Constructor...
If there are 32 concurrent processes, how will you modify the following code? Process i do...
If there are 32 concurrent processes, how will you modify the following code? Process i do { while (turn == j);                critical section; turn = j;                remainder section } while (true);
Modify the following code to use ONLY pointer arithmetic (no array expressions) and no for loops...
Modify the following code to use ONLY pointer arithmetic (no array expressions) and no for loops to do the same thing this code does. Be sure that you understand how the code works and how the pointer arithmetic relates to the array expression form. Provide liberal comments to explain what your pointer arithmetic is computing. #include <stdlib.h> #include <stdio.h> int main(int argc, char **argv) { int arg_count = 0; for (arg_count = 0; arg_count < argc; arg_count++) printf("%s\n", argv[arg_count]); }
Modify the following java code, utilizing a loop mechanism to enable the user to use the...
Modify the following java code, utilizing a loop mechanism to enable the user to use the calculator more than once. The program does the following:    It prompts the user to enter 2 numbers.    It prompts the user to choose an operation to perform on those numbers:    Operation 1: Addition.    Operation 2: Subtraction.    Operation 3: Multiplication.    Operation 4: Division.    It outputs the result of the operation.    It asks the user if they want...
Modify the previous program to use the Do-While Loop instead of the While Loop. This version...
Modify the previous program to use the Do-While Loop instead of the While Loop. This version of the program will ask the user if they wish to enter another name and accept a Y or N answer. Remove the "exit" requirement from before. Output: Enter the full name of a person that can serve as a reference: [user types: Bob Smith] Bob Smith is reference #1 Would you like to enter another name (Y or N)? [user types: y] Enter...
c++ /*USE STARTER CODE AT THE BOTTOM AND DO NOT MODIFY ANY*/ This is the entire...
c++ /*USE STARTER CODE AT THE BOTTOM AND DO NOT MODIFY ANY*/ This is the entire assignment. There are no more directions to it. Create an array of struct “employee” Fill the array with information read from standard input using C++ style I/O Shuffle the array Select 5 employees from the shuffled array Sort the shuffled array of employees by the alphabetical order of their last Name Print this array using C++ style I/O Random Number Seeding We will make...
// If you modify any of the given code, the return types, or the parameters, you...
// If you modify any of the given code, the return types, or the parameters, you risk getting compile error. // You are not allowed to modify main (). // You can use string library functions. #include <stdio.h> #include <stdlib.h> #include <string.h> #pragma warning(disable: 4996) // for Visual Studio #define MAX_NAME 30 // global linked list 'list' contains the list of employees struct employeeList {    struct employee* employee;    struct employeeList* next; } *list = NULL;              ...
Using Node.js as a Webserver 1. How do you modify a webserver.js code to include your...
Using Node.js as a Webserver 1. How do you modify a webserver.js code to include your name and date? Please include code. 2. Create a MongoDB database for the following group that includes member names and contact information and Include code: Gourp member exapmples: Pete 912-555-6666; Sam 912-111-3333; Mary 678-111-1111; and April 912-690-1111
Given the following code for AES Electronic Code Block implementation for the encryption functionality. Modify the...
Given the following code for AES Electronic Code Block implementation for the encryption functionality. Modify the code to create a function named ‘encryptECB(key, secret_message)’ that accepts key and secret_message and returns a ciphertext.          #Electronic Code Block AES algorithm, Encryption Implementation from base64 import b64encode from Crypto.Cipher import AES from Crypto.Util.Padding import pad from Crypto.Random import get_random_bytes secret_message = b" Please send me the fake passport..." password = input ("Enter password to encrypt your message: ") key= pad(password.encode(), 16) cipher...
A major element of this week's lesson is making sure that you understand how the so-called...
A major element of this week's lesson is making sure that you understand how the so-called accrual adjustments "correct" a cash-basis income statement. For this discussion you need to select ONE (1) real-world example of a business circumstance that would reasonably be the basis for an accrual adjustment in an income statement. Be sure to (a) briefly describe that circumstance, (b) describe what the appropriate adjustment to the cash basis income statement such that it would then represent an accrual...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT