//just go thru the simple prog
#include
#include
int main()
{
char str[5];
int i;
for(i=0;i<5;i++)
{
printf("\n enter the character :");
scanf("%c",str+i);
}
printf("\n %s\n ", str);
return 0;
}
predict what is the output
if u think output is
"
enter the character :a
enter the character :b
enter the character :c
enter the character :d
enter the character :e
abcde
"
then u r wrong..
output is
enter the character :a
enter the character :
enter the character :b
enter the character :
enter the character :c
a
b
c
"
this is the original output..
can someone please help and elaborate..
here when you type a then hit ENTER it takes ‘\n’ as a character thats wht you have got blank over there..
Yep Enter takes a character length ..
Plus u can enter the characters in one go i.e. abcde
u dont need to use a for loop to accept value for each index of the char array