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
- Which of the following techniques is most effective for improving the time efficiency of a program?
- Which of the following best describes a cookie in web technology?
- What is overfitting in the context of machine learning models?
- A data center wants maximum performance and direct hardware access for its virtual machines without the overhead of a host operating system. Which type of ...
- Given a set of activities with start and finish times: (1,4), (3,5), (0,6), (5,7), (3,9), (5,9), (6,10), (8,11), (8,12), (2,14), (12,16). If you apply the ...
- Which of the following is a primary reason for using threads instead of multiple processes for concurrent execution within a single application?
- Which statement is true regarding Inductor and capacitor filter respectively used in the rectifier?
- Which of the attributes shown below is a simple attribute?
- In the instruction "MOV R1, [R2+100]", the operand is fetched from memory address = content of R2 + 100. Which addressing mode is this?
- You are using Python's built-in dict to store custom objects. class MyObject: def __init__(self, value): self.value = value # Missi...
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)