typedef struct person { char name[20]; int age; double salary; } Employee; Employee *brad;Write a line of code that will allocate a person struct to which brad will point:
brad =
char name[20]; char first_name[10]; char last_name[20]; char *str_ptr; _________ name = str_ptr; _________ str_ptr = name; _________ if (name == "brad") { ... } _________ name = "sue"; _________ first_name = strdup("tom"); _________ strcpy(name, first_name); strcat(name, last_name); _________ name[10] = 'c'; _________ str_ptr[10] = 'c';
int count; char word[7]; char *string_ptr; int *int_ptr; int **double_int_ptr; strcpy(word, "puppy"); count = strlen(word); string_ptr = word; int_ptr = &count; double_int_ptr = &int_ptr; 1) printf("%s %d\n", word, count); 2) printf("0x%x 0x%x\n", int_ptr, double_int_ptr); 3) printf("0x%x\n", string_ptr);
Further suppose that the above variables are stored at the following memory addresses:
address of count = 0xffbef98c address of word = 0xffbef980 address of string_ptr = 0xffbef97c address of int_ptr = 0xffbef978 address of double_int_ptr = 0xffbef974
If there is no variable stored at a location, leave the line blank. If the contents of a memory location are unknown, put a ? in the location.
--------------------------- 0xffbef974 __________________ | | 0xffbef978 __________________ | | 0xffbef97c __________________ | | 0xffbef980 __________________ | | 0xffbef984 __________________ | | 0xffbef988 __________________ | | 0xffbef98c __________________ | | ---------------------------