I wrote a code for practice in C in Turbo c 3.1. My objective was to get the character output. My code is as follows:
#include<stdio.h>
#include<conio.h>
void main(){
char a[10],b;
int i;
clrscr();
for(i=0;i<10;i++)
a[i]='$';
for(i=0;i<10;i++){
b=getchar();
a[i]=b;
}
for(i=0;i<10;i++)
printf("%c",a[i]);
getch();
}
Here, I had to get 10 characters with what I had input but after execution I got only 5 characters. I couldn’t get the problem lying here.
Can you please help me?
Thanks in advance.
How about: