What's wrong with code

#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
string s;
for(int i=0;i<n;i++){
std::getline (std::cin,s);
}
sort(s,s+n);
for(auto c:s){
cout<<s<<endl;
}
return 0;
}

whenever i initialise string like string s1; it gives an error

hi @singhsimran567 can you tell mw what is the error? And please share your code using the CB IDE

the doubts are written as comments in the code

hi @singhsimran567

  1. c should be printed here, not s. It will give correct output after you do this. “S” is an array of strings so if you print s, it will give the address of the first element of the array.
    image
  2. please share the code which is giving the other errors im not getting what syntax you are using for those

this is the same code just have declared string differently
(string s instead of string s[100])

@singhsimran567 You need an array of strings, so that syntax is not correct for this use case

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.