How to write a C++ program doing the following :
a series of names with no blank characters and displays the number of the names having more than ten charaters. the name must not exceed 25 characters and the series ends when the user enters the word "end".

#define size 50     //minimum input 50
using namespace std;
int main()
    int i=0;;
string names[size];//store input
string names_dis[size];//save input condition fullfill
cout<<"Enter name"<<i+1<<"::"<<endl;
for(int j=0;j<i;j++)


You stated your objective and you've supplied code. However you haven't said what problem(s) you're having with your code.

Edited 6 Months Ago by tinstaafl

#define size 50     //minimum input 50

You're asking for trouble #defining size to equal a number (or anything else). You got away with it here, but what if you had a program that used vectors and you wanted to use vector's size function?

vector<int> intVector;
cout << intVector.size();

Preprocessor changes "size" to "50", so the compiler has to try to make sense of

vector<int> intVector;
cout << intVector.50(); // error

It would be better to make the size upper-case if you're going to #define it. It's part of the naming convention to make it all upper-case anyway, even if it was a name like ABCDEFGHIJ that isn't going to be a common function name like "size". Constants and #define's are upper-case. Easier to read the code that way.

#define SIZE 50

Edited 6 Months Ago by AssertNull: grammar

This article has been dead for over six months. Start a new discussion instead.