Is a = getchar()
equivalent to scanf(\"%c\",&a);
?
Is putchar(a)
equivalent to printf(\"%c\",a);
where a
They do the same thing here. However, if you know you are just doing characters then getchar
and putchar
will be more efficient, since the printf
and scanf
variants will have to parse the string each time to determine how to process your request. Plus, they may be called in a lower level library meaning you may not have to have the printf
/scanf
linked if they are not needed elsewhere.