Hi i just started learning C++ & we were given homework to write code that will show names numbered to six and display the longest name entered. i have managed to show the names going in numeric order just can't display the longest one. Thanks for any future help... (Also don't know how to inclose code properly so sorry)

//Creating programe to store names & display names with max of 30 characters
#include <iostream.h>
main()

{
	char name[6][20];
	int num = 1, a = 1, row;
	
		
		//for loop to cycle 6 names & proceed to next step
		cout << "Please Input 6 Names\n";
		cout << "\n";
				for (row = 0; row < 6; row++){
			cout << "Enter Name:" << num++ << " of 6\n";
					cin >> name[row];
							}

		cout << "\n";
//Cout is used on each of them to show the names in numeric order		
		{ 
		cout << "The List Of Names Are:\n";
			
		
				for (row = 0; row < 6; row++){
		cout << a++ << ". " << name[row] << "\n";

		
							}
		}

		return 0;

	}

> //Creating programe to store names & display names with max of 30 characters char name[6][20]; There's the first problem.

> #include <iostream.h>
This is old-style C++.
New C++ should use

#include <iostream>
using namespace std;

If your compiler doesn't like that, then you definitely need a newer compiler.

> main()
Whilst this used to work, because it was assumed that main would return an int, you need to understand that such implicit behaviour is obsolete and you need to say what you mean, namely int main ( ) As for the length, then look at #include <cstring> // or string.h if you insist on older compilers Then later on len = strlen( name[i] );

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