Answer:
#define LSH_RL_BUFSIZE 1024
char *lsh_read_line(void)
{
int bufsize = LSH_RL_BUFSIZE;
int position = 0;
char buffer = malloc(sizeof(char) bufsize);
int c;
if (!buffer) {
fprintf(stderr, "lsh: allocation error\n");
exit(EXIT_FAILURE);
}
while (1) {
// Read a character
c = getchar();
// If we hit EOF, replace it with a null character and return.
if (c == EOF || c == '\n') {
buffer[position] = '\0';
return buffer;
} else {
buffer[position] = c;
}
position++;
// If we have exceeded the buffer, reallocate.
if (position >= bufsize) {
bufsize += LSH_RL_BUFSIZE;
buffer = realloc(buffer, bufsize);
if (!buffer) {
fprintf(stderr, "lsh: allocation error\n");
exit(EXIT_FAILURE);
}
}
}
}
Explanation:
Answer:
Write the following nonsensical paragraph:
Explanation:
I learned how to navigate the computer efficiently. I learned how to use Ctrl + (key) to quickly do (something). ( Now reword that multiple times with different commands. ) Now I can harness my inner laziness to browse the computer at a faster speed.
Answer:
The minimum number of bits necessary to address 8K words is 13.
Explanation:
You have the number of words to address that is 8000 words, a word is the smallest addressable memory unit.
8000 words can be addressed with units. Now you have to find the value of n that approximates to the number of words.
So you can see that 13 bits are needed to address 8K words.