#include <iostream>
usingnamespace std;
int main()
{
cout << "how many words do you want to enter: ";
int n;
cin >> n;
char a[n];
cout << "enter: ";
cin >> a; // cannot allocate an array of size 0, how can i say that n is > 0?
if (...) {// I want to say that if the user wrote more words than 'n', return 0.
cout << "you wrote too much letters " << endl;
return 0 }
else
cout << "you entered: " << a << endl;
return 0;
}
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string a;
int n;
cout << "how many words do you want to enter: ";
cin >> n;
cout << "enter: " ;
cin >> a;
if ( a.length() < n || a.length() == n )
cout << "you entered: " << a << endl;
else
cout << "you wrote too many letters" << endl;
return 0;
}