Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C | String | Question 10

  • Difficulty Level : Basic
  • Last Updated : 28 Jun, 2021


Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.



#include <stdio.h>
   
void my_toUpper(char* str, int index)
{
    *(str + index) &= ~32;
}
   
int main()
{
    char* arr = "geeksquiz";
    my_toUpper(arr, 0);
    my_toUpper(arr, 5);
    printf("%s", arr);
    return 0;
}

(A) GeeksQuiz
(B) geeksquiz
(C) Compiler dependent


Answer: (C)

Explanation: The memory for the string arr is allocated in the read/write only area of data section. The choice is compiler dependent. In the newer version of compilers, the memory is allocated in the read only section of the data area. So any modification in the string is not possible.
In older version compilers like Turbo-C, modification is possible.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!