subject

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
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:40, jennsou
Adna sequence encoding a five-amino acid polypeptide is given below. …… …… locate the sequence encoding the five amino acids of the polypeptide, and identify the template and coding strand.
Answers: 1
image
Computers and Technology, 22.06.2019 04:30, Lilabbychichi
Ryan is working on the layout of her web page. she needs to figure out where her header, navigation bar, text, and images should go. what technique can her?
Answers: 1
image
Computers and Technology, 22.06.2019 14:40, coryowens44
For this assignment you have to write a c program that will take an infix expression as input and display the postfix expression of the input. after converting to the postfix expression, the program should evaluate the expression from the postfix and display the result. what should you submit? write all the code in a single file and upload the .c file. compliance with rules: ucf golden rules apply towards this assignment and submission. assignment rules mentioned in syllabus, are also applied in this submission. the ta and instructor can call any students for explaining any part of the code in order to better assess your authorship and for further clarification if needed. problem: we as humans write math expression in infix notation, e. g. 5 + 2 (the operators are written in-between the operands). in computer's language, however, it is preferred to have the operators on the right side of the operands, ie. 5 2 +. for more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix write a program that takes an "infix" expression as input, uses stacks to convert it into postfix expression, and finally evaluates it. it must support the following operations: + - / * ^ % ( example infix expression: (7-3)/(2+2) postfix expression: 7 3 2 2 result: rubric: 1) if code does not compile in eustis server: 0. 2) checking the balance of the parenthesis: 2 points 3) incorrect postfix expression per test case: -2 points 4) correct postfix but incorrect evaluation per test case: -i points 5) handling single digit inputs: maximum 11 points 6) handling two-digit inputs: 100 percent (if pass all test cases)
Answers: 3
image
Computers and Technology, 23.06.2019 07:00, sugaree95
What are three software programs for mobile computing?
Answers: 1
You know the right answer?
Q6 common mistakes in c

5 points

each of the following code samples below is...

Questions in other subjects:

Konu
Mathematics, 20.09.2019 14:30
Konu
World Languages, 20.09.2019 14:30
Konu
Mathematics, 20.09.2019 14:30