c2tarun
February 5th, 2012, 04:34 AM
Hi friends
I tried following code in gcc compiler.
#include <stdio.h>
int main()
{
char a;
int i = 0;
while(i<10){
a=getchar();
printf("%c,%d\n",a,(int)a);
}
}
I am getting following as output
$ ./checkgetchar < getcharInput
T,84
a,97
r,114
u,117
n,110
K,75
u,117
m,109
,10
a,97
The content of input file getcharInput is
TarunKum
ar123
Can anyone please explain me why is it taking two inputs after m and why am I not getting the ASCII code of return. :(
I tried following code in gcc compiler.
#include <stdio.h>
int main()
{
char a;
int i = 0;
while(i<10){
a=getchar();
printf("%c,%d\n",a,(int)a);
}
}
I am getting following as output
$ ./checkgetchar < getcharInput
T,84
a,97
r,114
u,117
n,110
K,75
u,117
m,109
,10
a,97
The content of input file getcharInput is
TarunKum
ar123
Can anyone please explain me why is it taking two inputs after m and why am I not getting the ASCII code of return. :(