i'm trying to count the number of people (i called speakers) that are on the list. But, in order to do that, I have to know that there is actually some name is written in that person's spot. In other words, I want the "for" loop to skip/don't count the ones that are empty.

int showCount(Speaker sp[]){
    int count = 0;
    for(int i = 0; i < 10; i++)
    {
        if ( (strcmp(sp[i].name, "_") != 0) || (strcmp(sp[i].name, "\0") != 0) ){
	   count++;
	}
    }
    cout << "There are " << count << " people that are already on the list." << endl;
	
return count;
}

but, everytime I run it, my program keeps counting till 10 and displays
"There are 10 people...blah blah"
Am I missing anything?

Thank you


p.s. this is just one part of my program

Member Avatar for embooglement

What exactly are you passing it? Right now "count" represents the number of people that have blank names. Is that what you wanted?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.