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...
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?
How this command used for and provide examples for each one. Commands: 1-file 2-find 3-pwd 4-ln...
How this command used for and provide examples for each one. Commands: 1-file 2-find 3-pwd 4-ln 5-stat 6- cmp, comm, and diff 7-md5sum 8-du 9-gzip 10-gunzip 11-bzip2, and bunzip 12-cpio 13-tar 14-wc 15-vi editor
What are butterfly fractures and why do they command so much attention? I am having a...
What are butterfly fractures and why do they command so much attention? I am having a hard time finding information about it. if you use a source to answer the question could you please include it so i may review it? Thank you
Unix / Linux 6. vi editor: In vi command mode, what are the keystrokes you would...
Unix / Linux 6. vi editor: In vi command mode, what are the keystrokes you would type to... Quit the vi editor and save any changes? 7. C language source files, by convention, have the suffix ".c". The associated "header" files have the suffix ".h". What is the command to perform the following task: List all the C source and C header files in the current directory. [Hidden files may remain hidden.] 8. C language source files, by convention, have...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT