Q6 common mistakes in c
5 points
each of the following code samples below is...
![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 05.02.2020 12:56 leylaanddade
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
![ansver](/tpl/images/cats/User.png)
Answers: 2
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 12:30
Which of the choices sean are not true when considering virus behavior
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 15:00
The three logical operators used to write compound conditions are "and," "or," and "not." a: true b: false
Answers: 2
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 04:31
Acloud service provider uses the internet to deliver a computing environment for developing, running, and managing software applications. which cloud service model does the provider offer? a. iaas b. caas c. maas d. paas e. saas
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 16:10
What is the ooh? a. omaha occupation handbook b. online occupational c. occupations online d. occupational outlook handbook select the best answer from the choices provided
Answers: 3
You know the right answer?
Questions
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/biologiya.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 09.12.2021 20:50
![question](/tpl/images/cats/es.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 09.12.2021 20:50
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 09.12.2021 20:50
![question](/tpl/images/cats/mat.png)
Mathematics, 09.12.2021 20:50
![question](/tpl/images/cats/mat.png)
Mathematics, 09.12.2021 20:50
![question](/tpl/images/cats/biologiya.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mkx.png)
Arts, 09.12.2021 20:50
![question](/tpl/images/cats/mat.png)
Mathematics, 09.12.2021 20:50
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/User.png)
SAT, 09.12.2021 20:50
![question](/tpl/images/cats/obshestvoznanie.png)
Social Studies, 09.12.2021 20:50
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 09.12.2021 20:50