hello
i am having a trouble in taking input for the character type in c.the behavior of my source code is unusual.
my code is:
int n,i;
char *ps;
printf("Total no:");
scanf("%d",&n);
ps=(char *)calloc(n,sizeof(char));
for(i=0;i<n;i++) {
printf("Enter character %d:",i+1);
scanf("%c",ps+i);
}
then as per my requirement it should take input for all no. of n's but it's not working fine it will not take any input when the loop runs for the first time then it take input when loop runs 2 time and then in 4 time and so on.
so please tell me what's the error with my code?
-Thanks in advance.