i tried to solve this question by writing the 2 d array nd my code is -
#include
#include
#include
using namespace std;
void largest_string(char arr[][1000], int N);
int main()
{
char arr[100][1000];
int N;
cin>>N;
cin.get();
for(int row = 0; row<N; ++row)
cin.getline(arr[row], 1000);
largest_string(arr, N);
return 0;
}
void largest_string(char arr[][1000], int N)
{
int x, y = INT_MIN;
for(int row = 0; row<N; ++row)
{
if(strlen(arr[row])>y)
{
y=strlen(arr[row]);
x=row;
}
}
cout<<"The max length among the strings is "<<y<<endl<<"that string is "<<endl<<arr[x]<<endl;
return;
}
this is not giving me the desirable answer .
what is wrong in this code???