Question
A C function attempts to copy a substring. #include #include #include char* copy_substring(const char* source, int start_index, int length) { char* dest = (char*)malloc(length + 1); if (dest == NUL
- L return NULL; strncpy(dest, source + start_index, length); dest[length] = '\0'; // Null-terminate return dest; } int main() { const char* original = "Programming"; // Length 11 char* sub = copy_substring(original, 5, 10); // start_index=5, length=10 if (sub) { printf("Substring: %s ", sub); free(sub); } return 0; } What is the most likely issue with copy_substring when called as in main?
More IT Operating System Questions
- What is the primary advantage of using recursion over iteration for certain problems (e.g., tree traversals)?
- Which Linux/Unix command is used to search for a specific pattern of text within one or more files?
- Fill in the correct option for 28 blank space.
- In a Breadth-First Search (BFS) algorithm for graph traversal, what is the primary role of a queue?
- Which OOP principle focuses on showing only essential information and hiding the complex implementation details from the user?
- Which of the following is a NoSQL database commonly used in Big Data?
- Which of the following best defines software testing?
- What does the Hamming distance between two binary strings represent?
- Which of these is an example of PaaS (Platform as a Service)?
- Using the SCAN disk scheduling algorithm, the disk head starts at cylinder 65 and is initially moving toward higher cylinder numbers, with valid cylinders ...
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
- 200 Questions with Detailed Solutions
- Section-wise Coverage (GA, English, Quant & Reasoning)