Computers and Technology

Q6 common mistakes in c

5 points

each of the following code samples below is making a common mistake in c. from the options, select the error type that best categorizes the mistake.

you can assume all the code has the necessary #include macros. also you should assume that the system is 32-bit.

1) #define password "correct horse battery staple"
char *check_permissions (char *user_guess) {
if (user_guess = password) {
return "access granted";
}
return "access denied";
}
probable segfault

double free

incorrect use of free

logic error

memory leak

no error

2) #define password "correct horse battery staple"
char *check_permissions (char *user_guess) {
if (user_guess == password) {
return "access granted";
}
return "access denied";
}
probable segfault

double free

incorrect use of free

logic error

memory leak

no error

3) int main () {
char *x = malloc(0x * sizeof(char));
x[0] = '! ';
}
probable segfault

double free

incorrect use of free

logic error

memory leak

no error

4) int foo () {
int *x = malloc(20);
x[0] = x[1] = 1;
x[2] = x[0] + x[1];
x[3] = 99;
return x[3];
}
probable segfault

double free

incorrect use of free

logic error

memory leak

no error

5) int main () {
char *x = "patrick";
printf("%s", x);
free(x); // tidy up
}
probable segfault

double free

incorrect use of free

logic error

memory leak

no error

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:00, silvijaaa
The two main ways in which marketers address the competition with their strategies are by satisfying a need better than a competition and by
Answers: 2
image
Computers and Technology, 23.06.2019 11:30, kieante01
The most accurate readings that you can take on an analog vom are when the meter's pointer is at the a. center scale. b. extreme right. c. near right. d. extreme left.
Answers: 1
image
Computers and Technology, 23.06.2019 16:30, rileysndr1782
Monica and her team have implemented is successfully in an organization. what factor leads to successful is implementation? good between different departments in an organization leads to successful is implementation.
Answers: 1
image
Computers and Technology, 23.06.2019 17:00, ayoismeisjjjjuan
The camera still is bad even with the new iphone xr and especially in low light it is even worst because you can see the pixels more if its in low light. if all you apple customers want apple to fix this then lets fill there feedback with complaints about the can apple do to fix this issue?
Answers: 1
Do you know the correct answer?
Q6 common mistakes in c

5 points

each of the following code samples below is...

Questions in other subjects:

Konu
Physics, 17.08.2021 18:00