Problem in executing code

here is my code


I am getting correct output in online compiler and code blocks but getting segmentation fault here.
please rectify the code
and also can you please tell how to take input as string and then pass string in function and then execute the code