Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exiting via keyboard input

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How would i go about exiting this function with an input 'X' from the keyboard when the name is read in.

thanks :))

Code:
	int i;
	for(i=0;i<=9;i++,*ptr++)
	{
	printf(&quot;\n\tName	:	&quot;);
	scanf(&quot;%s&quot;,&ptr->name);
	printf(&quot;\n\tID	:	&quot;);
	scanf(&quot;%d&quot;, &ptr->identity);
	}
 
int i;
char fEnd = 0;

for(i=0;i<=9 && !fEnd;i++,*ptr++)
{
printf(&quot;\n\tName : &quot;);
scanf(&quot;%s&quot;,&ptr->name);
if ( strcmp ( ptr->name, &quot;X&quot; ) == 0 ||
strcmp ( ptr->name, &quot;x&quot; ) == 0 )
{ fEnd = 1; } else
{ printf(&quot;\n\tID : &quot;);
scanf(&quot;%d&quot;, &ptr->identity); } }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top