C Programming:-
What is the type of the variable x?
uint8_t *x[256];
(Do not use spaces in your answer)
What type does the variable x decay to when used in an expression?
uint8_t *x[256]
(Do not use spaces in your answer)
Consider the following function whose purpose is to return an array of 3 strings that are initialized to the strings in the character arrays s1, s2, and s3:
#include <string.h> #include <stdlib.h> char** stringstoarray(char* s1, char* s2, char* s3) { // dynamically allocate space for the pointer array itself. char** strings = ________________________ strings[ 0 ] = strdup(s1); // initialize first string strings[ 1 ] = strdup(s2); // initialize first string strings[ 2 ] = strdup(s3); // initialize third string return strings; }
In order for the function for the function to carry out its purpose, fill in the blank with the necessary code.
Do not use spaces in your answer and don't forget a semi-colon at the end of your answer.
(i) uint8_t is of unsigned int of length 8bits data type.
(ii) uint8_t has a result of 2^8=256. It is because 255 is the maximum value of an unsigned int or an uint8_t as the range varies from 0-255. So if we put a value of 256, our result would be 0.
(iii) char** strings = new strings *[3];
In this the strings is pointing to 3 string arrays which will further point to the data.
Hope this helps you. For further queries please add your comment below. Please give an upvote. Thank you.
Get Answers For Free
Most questions answered within 1 hours.