My problem is that when i enter a second name into t it just ignores it or crashs the system, am running borland 5.5. When i enter Oli its fine but when i enter Oli Dl it crashs.

#include<iostream.h>
#include<iomanip.h>
void main()
{
	char t[100] = {0};
	char key = 'n';
	do 
	{
		key = 'n';
		cout<<"Please enter your name"<<endl;
		cin >> t;
	
		cout<<"If your not called " <<t<< " Press n"<<endl;
		cin >> key;
	}
	while (key == 'n');

	cout<<"test";

	cin.get();
	cin.get();
}

My problem is that when i enter a second name into t it just ignores it or crashs the system, am running borland 5.5. When i enter Oli its fine but when i enter Oli Dl it crashs.

#include<iostream.h>
#include<iomanip.h>
void main()
{
char t[100] = {0};
char key = 'n';
do
{
key = 'n';
cout<<"Please enter your name"<<endl;
cin >> t;

cout<<"If your not called " <<t<< " Press n"<<endl;
cin >> key;
}
while (key == 'n');

cout<<"test";

cin.get();
cin.get();
}

It shouldn't work well, but I don't know why it would crash the system. I think you want to use getline, not the >> operator. >> only reads till the first space. Try using this as input:

Oli n

"Oli" will end up in the t variable and 'n' will end up in the key variable. You'll get a prompt again. You won't if you input something like:

Oli F

Try using getline rather than >>. See the example here.

http://www.cplusplus.com/reference/iostream/istream/getline.html

Also do a search about why you shouldn't use void main () . Also, try dropping the ".h" off of your #include statements.

My problem is that ...

... you can't be bothered to read any of the requested information posted all over this site about CODE tags, like
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) on the background of the box you actually typed you message in

Also do a search about why you shouldn't use void main () . Also, try dropping the ".h" off of your #include statements.

No need to search. Here's a link.

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.