Question: Consider the following C code which has several memory-related problems (but compiles, and even gives reasonable output sometimes!): #include #include struct person { char* name;
Consider the following C code which has several memory-related problems (but compiles, and even gives reasonable output sometimes!):
#include
#include
struct person { char* name;
};
struct person* create_person(char* name){ struct person newperson = {name}; return &newperson;
}
int main() { char *str = malloc(sizeof(char) * 10);
printf("Enter a name: "); scanf("%s", str); if (str) { struct person* p1 = create_person(str);
printf("Your person's name: \"%s\" ", p1->name); free(str);
}
return 0;
}
Use this for the next few questions.
1. Consider the functional programming concept of higher order functions. Find example code illustrating this concept and written in Clojure somewhere on the internet, paste it in, and explain how it works and how it exhibits the concept.
2.Consider the functional programming concept of lazy evaluation. Find example code illustrating this concept and written in Clojure somewhere on the internet, paste it in, and explain how it works and how it exhibits the concept.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
