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


Please Help Members By Posting Answers For Below Questions

What does %c do in c?

578


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

603


What is linear search?

672


What are near, far and huge pointers?

640


What is the difference between typedef struct and struct?

592






What is equivalent to ++i+++j?

639


What are dangling pointers? How are dangling pointers different from memory leaks?

615


What are different storage class specifiers in c?

611


What does c mean before a date?

585


What type of function is main ()?

581


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.

615


What is pragma c?

607


why programs in c are running with out #include? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }

1314


What is union and structure in c?

606


Explain what is dynamic data structure?

642