+ 1

last string length

How can I get length of last string in array;What's wrong in here I'm begginer so sorry (C++) #include <iostream> #include <string> using namespace std; int n,z; int main(){ cin>>n; string a[n]; for(int i=1;i<=n;i++){ cin>>a[i]; } z=a[n].length(); cout<<z; }

2nd Mar 2019, 4:07 PM
Slavisa
Slavisa - avatar
1 Odpowiedź
0
sizeof(a[n]) instead of .length() I think
2nd Mar 2019, 6:11 PM
SuPeRTRoNeRD