I\'m learning C from K&R\'s \"The C Programming Language\" book. I\'m doing the exercises specified in the book. I\'m on exercise number 1.16, but I don\'t understand it
here is my version:
int getline(char s[],int lim)
{
int c,i;
for(i=0;i1)
{
if(len>max)
{
max=len;
copy(longest,line);
}
}
if(max>0)
{
printf("%d:%s",max,longest);
}
return 0;
for some unknown reasons ,the example code doesn't work in my pc particularly,when the condition is 'len>0',the loop won't end i think the main reason is that when you type nothing,but you still have to press enter,so it is received as '\n',and the len is 1; i think it satisfy the requirement that print the length of arbitrarily long input lines, and as much as possible of the text. And it works like this