This looks like a homework assignment, so all I will say is:
#include<cstdlib> is not being used for anything here.
getline is very good at getting lines. Read about it.
(line[0]==line[n])
This is comparing the first character of the string to the rest of the string. You want to be comparing a to the rest of the string, not whatever the first character has to be.
You don't reset your count ? Unless you want a cumulative answer.