Question

In: Computer Science

Question 3: What do the following vim commands do in command mode? ZZ :w! i dd...

Question 3: What do the following vim commands do in command mode?

ZZ

:w!

i

dd

x

yy

p

Question 4: Review the following code. If you were to print out all the dereferenced values of the three pointer variables and the array, what is the output?

(note: if possible explain how the output changed.)

int array[] = { 30, 40, 50, 60, 70, 80 };

int *ptrA = array;

int *ptrB = ptrA + 4;

int *ptrC = ptrB--;

array[ 1 ] = 2;

*ptrB = *ptrC - 2;

*ptrC = 100;

array[ 3 ] = *ptrA++;

ptrC = ptrB + 2;

Solutions

Expert Solution

1)

ZZ

Write current file, if modified, and exit.

:W!

Write the current file and exit always.

i

Insert text before the cursor [count] times.

dd

Delete [count] lines

x

Delete [count] characters before the cursor.

yy

it copies the line for you to put into the file immediately. This command "yanks" the current line into the vi general buffer.

p

it paste the previously deleted text after the cursor.

2)

usage of 'int' here is not the correct method.

using 'int'  ("%d")  with pointers is incorrect and invokes undefined behavior.

Pointers should be printed with %p not %d because the number might be too big , so it became overflow.

if you print with "%d" then the values are:

array values are: -2112859744
-2112859740
-2112859736
-2112859732
-2112859728
-2112859724


ptr A -2112859740
ptr B -2112859732
ptr C -2112859724


Related Solutions

a) Observe the following Linux commands and work out what each command does: 1) $ ls...
a) Observe the following Linux commands and work out what each command does: 1) $ ls –al 2) $ /etc/profile 3) $ chmod 200 final_assignment.txt b) Consider a scenario where Bob has downloaded his messages to the local machine with an access of POP3, he can create mail folders and move the downloaded messages into the folders. Bob can then delete messages, move messages across folders, and search for messages (by sender name or subject). But this paradigm—namely, folders and...
***************************************************** * USE UBUNTU (Linux) TERMINAL MODE COMMANDS ONLY * * DO NOT USE ANY EDITORS...
***************************************************** * USE UBUNTU (Linux) TERMINAL MODE COMMANDS ONLY * * DO NOT USE ANY EDITORS TO CREATE THIS PROGRAM * ***************************************************** 1) Create a file called lastNameFirstNameInitialpgm3.sh ex: robinsonMpgm1.sh 2) Append to the above file the necessary commands that when this file is executed it will display the following: - Using your own set of multi-line comments enter your program identification as described in the Syllabus, example: <<ID ************************************************** Author : Your Name Course : Course Name and Times...
QUESTION 1 User can interact with a PC using a command-line interface by issuing commands to...
QUESTION 1 User can interact with a PC using a command-line interface by issuing commands to the program in the form of successive lines of text. True False 1 points    QUESTION 2 A machine code (object code) is generated by an executor for process. True False 1 points    QUESTION 3 In case of all the resources are being used, the new process with a low priority might not get its resource forever. True False 1 points    QUESTION...
QUESTION 1 Match the following LINUX/UNIX commands with what they do. du    whereis users who...
QUESTION 1 Match the following LINUX/UNIX commands with what they do. du    whereis users who am i A. display a compact list of users currently logged in B. locate the binary, source, and manual page files for a command C. summarize disk usage D. who am i currently logged in as on the Linux server. QUESTION 2 What rm command option (flag) would you use to remove a file that begins with a - (hyphen)? -f -p --   ...
I need to combine two programs that can do the following (a) what ls command does...
I need to combine two programs that can do the following (a) what ls command does and (b) to check each file name to print its content if its name has ".lst" extension. These are the two programs Program - 1 /* * simple-ls.c * Extremely low-power ls clone. * ./simple-ls . */ #include <sys/types.h> #include <dirent.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { DIR *dp; struct dirent *dirp; if (argc != 2) { fprintf(stderr, "usage: %s...
What command do I use in R to compute the probability that a t distribution with...
What command do I use in R to compute the probability that a t distribution with 36 df exceeds 2.5 and then how do I compute the lower 10th percentile of a t distribution with 54 df (using what command in (R)?
Give the PowerShell command that would display the “Path” environment variable. What two PowerShell commands will...
Give the PowerShell command that would display the “Path” environment variable. What two PowerShell commands will display all of the users currently logged into a server? What command would give helpful information about the Get-Command cmdlet.
linux Using the grep or egrep commands, what would be the full command (including regular expression)...
linux Using the grep or egrep commands, what would be the full command (including regular expression) to view only the lines in the file /boot/grub/grub.cfg that DO NOT begin with a hashtag (the # sign). In other words, what would be the command to print all the lines in this file that do not begin with this character.
how do i interpret mean, mode and median?
how do i interpret mean, mode and median?
Use Workbench/Command Line to create the commands that will run the following queries/problem scenarios. Use MySQL...
Use Workbench/Command Line to create the commands that will run the following queries/problem scenarios. Use MySQL and the Colonial Adventure Tours database to complete the following exercises. 1. List the last name of each guide that does not live in Massachusetts (MA). 2. List the trip name of each trip that has the type Biking. 3. List the trip name of each trip that has the season Summer. 4. List the trip name of each trip that has the type...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT