if my c code is
#include<stdio.h>
int main()
{
int c;
while((c=getchar())!=EOF)
{
putchar(c);
}
getch();
return 0;
}
I want to know whether int c woud be converted into char , or the input character would be converted into int and then be stored in c.
getchar returns an int and putchar expects an int so there is no need of conversion. char in name may be confusing for you. But type int also allows to accommodate some special values for ex: EOF
From the man page of getchar()
int getchar(void);
So, why'd think of conversion, anyway? The return type of getchar() is int, being stored into an int variable.
Same goes for putchar() also.
int putchar(int c);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With