Hi all,

I am having a rather interesting problem. I was doing a program and I was trying to read a string in a subfunction after reading an integer in main function. Now a problem occured, I couldnt read the string. The reading of string does not work.

It worked properly when the subfunction was called without reading the integer. The problem showed up when I tried to call the fucntion after reading the integer.

This is a small program which depicts the bug.

Code:
#include<stdio.h>
void test()
{
    char x;
    printf("testt");
    scanf("%c",&x);

}

main()
{
    int c;
    scanf("%d", &c);
    test();
}
I would love to know the reason for this strange problem.

I tried flushing the stdin also. It didnt work as well.

Thanks