Posted by Hasan on 1999-09-28
It has been told always that usage of fgets or scanf is not an efficient way
to read keyboard input streams. I thought about using the following code but
even though it complies ok, it does not run? can anyone help? or anyother
suggestions instead of this code...?
thx
#include <stdio.h>
void main()
{
char c;
int i=0;
printf("please enter the name");
for (c=getchar();c!='\n';c=getchar())
{
i+=1;
}
printf("your name is %s and has %d characters",c,i);
}
Sponsored by Wrox Press - www.wrox.com. Programmer to Programmer (TM)
Previous post | Next post | Timeline | Home