This reads a string until user inputs a new line character, considering the white spaces also as string
#include<stdio.h>
#include<conio.h>
void main()
{
char yname[30];
printf("enter ur name\n");
scanf("%[^\n]",yname);
printf("\n%s",yname);
getch();
}
/*
output:
enter ur name
ram charan teja
ram charan teja
*/
#include<stdio.h>
#include<conio.h>
void main()
{
char yname[30];
printf("enter ur name\n");
scanf("%[^\n]",yname);
printf("\n%s",yname);
getch();
}
/*
output:
enter ur name
ram charan teja
ram charan teja
*/
No comments:
Post a Comment