String sort small doubt

In the following code why do I need to input the strings n+1 times ?How can I correct the problem?
For Example : Input is

3
bat
apple
batman

Code: https://ide.codingblocks.com/#/s/21725
Problem: https://hack.codingblocks.com/contests/c/262/103

#include
#include
#include
using namespace std;

bool compare(string a,string b)
{
bool c=true;
for(int i=0;a[i]!=’\0’&&b[i]!=’\0’;i++)
{
if(a[i]!=b[i])
c=false;
}
if©
return a.length()>b.length();
else
return a<b;
}

int main() {
int n;
string s[100];
cin>>n;
for(int i=0;i<=n;i++)
getline(cin,s[i]);
sort(s,s+n+1,compare);
for(int i=0;i<n;i++)
cout<<s[i]<<endl;
return 0;
}