main()
{
char *ptr = "Ramco Systems";
(*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s\n",ptr);
}
Find the Outputs?
Answer Posted / chappa
The first increment is incorrect, since it will try to
increment the value of 'R' but will end up giving
Segmentation fault.
Second ptr++ is valid as it will shift the pointer from 'R'
to 'a'. The second print statement would have printed "amco
Systems", the compiler gives Seg fault due to the previous
incorrect increment.
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What does %c do in c?
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode
What is linear search?
What are near, far and huge pointers?
What is the difference between typedef struct and struct?
What is equivalent to ++i+++j?
What are dangling pointers? How are dangling pointers different from memory leaks?
What are different storage class specifiers in c?
What does c mean before a date?
What type of function is main ()?
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
What is pragma c?
why programs in c are running with out #include
What is union and structure in c?
Explain what is dynamic data structure?