SyntaxFix
Write A Post
Hire A Developer
Questions
Your scanf("%s", s); is commented out. That means s is uninitialized, so when this line ln = strlen(s); executes, you get a seg fault.
scanf("%s", s);
ln = strlen(s);
It always helps to initialize a pointer to NULL, and then test for null before using the pointer.