Obviously, you want an array of strings:
char string[10][10];
But this is not safe as it would fails if either you enter more than 10 strings or if any of those are longer that 10 characters including null terminator.
So you should add validation that the number entered by the user is less than the array size. Better yet would be to use
std::vector<>
instead.
Then for each string, you should really use
std::string
instead of C style string. That would fix the problem of entering entering too much data. By the way, if you modify the code to use
std::string
, you might have to rename variable
string
to something else to avoid ambiguity (in fact, it would be a good idea to do it anyhow).
Then, if you want to output the length of each string, the code for outputting those length should be inside the loop. Also, second loop should start at 0 to output the length of the first string. You probably also want to add either a space or a new line between each outputted number.
And finally, if you update the code to use
std::string
, you should call member function
length()
to get the length.
Also, you should really include standard headers whenever possible like
#include <string> // Note the absence of .h suffix</string>
And then either add a
using
statement for
std
namespace or qualify all names manually.
I would recommand you to read good books on C++ and to avoid mixing C style code with C++ code.
About the error
First of all, you should learn to correctly read error message as the problematic conversion is between
char
(a single char from the array) and
const char *
(the expected parameter of strlen).