Input a name and print first name (using two string).
#include <stdio.h>
#include <conio.h>
void main ( )
{
char nm[80], nm1[80];
int i, ln;
clrscr ( );
printf("\n\n\n\t\t Enter a name....:"); gets (nm);
for ( ln = 0; nm[ln] != '\0'; ln++);
for ( i = 0; i < ln; i++ )
{
if ( nm[i] != ' ' )
nm1[i] = nm[i];
else
break;
}
nm1[i] = '\0';
printf("\n\n\n\t\t FIRST NAME....: %s", nm1);
getch ( );
}
Click here to contact us
#include <stdio.h>
#include <conio.h>
void main ( )
{
char nm[80], nm1[80];
int i, ln;
clrscr ( );
printf("\n\n\n\t\t Enter a name....:"); gets (nm);
for ( ln = 0; nm[ln] != '\0'; ln++);
for ( i = 0; i < ln; i++ )
{
if ( nm[i] != ' ' )
nm1[i] = nm[i];
else
break;
}
nm1[i] = '\0';
printf("\n\n\n\t\t FIRST NAME....: %s", nm1);
getch ( );
}
Click here to contact us
No comments:
Post a Comment