I have a few questions about C syntax.
ch = (char *) malloc( sizeof( char ) * strlen(src) );
What do the first brackets mean (char *) ?
I d like to add to @Alok Save s answer. He has analysed it correctly however, another simple solution exists for that case and that is to use scanf with a whitespace in the string format as follows:
scanf(" %c", &variable);
This is because %c does not absorb the newline character like others(like %d) do. Any whitespace in the format string will cause scan to absorb all consecutive whitespaces thereby obviating the need for another scanf statement.
Hope this helps!