fork download
  1. #include <stdio.h>
  2. #define MAXLINE 5
  3.  
  4. int getline(char s[],int lim);
  5. void copy(char t1[], char from[]);
  6.  
  7. int main(){
  8. int len;
  9. int max;
  10. char line[MAXLINE];
  11. char longest[MAXLINE];
  12. max=0;
  13. while((len=getline(line, MAXLINE))>0){
  14. if (len>max){
  15. max=len;
  16. copy(longest,line);
  17. }
  18. }
  19. if (max>0)
  20. printf("%s",longest);
  21. return 0;
  22. }
  23.  
  24. int getline(char s[], int lim){
  25. int c,i;
  26. for (i=0;i<lim-1 && (c=getchar())!=EOF && c!='\n';++i)
  27. s[i]=c;
  28. if (c=='\n'){
  29. s[i]=c;
  30. ++i;
  31. }
  32. s[i]='\0';
  33. return i;
  34. }
  35.  
  36. void copy(char t1[], char from[]){
  37. int i;
  38. i=0;
  39. while ((t1[i]=from[i])!='\0')
  40. ++i;
  41. }
Success #stdin #stdout 0s 4480KB
stdin
Standard input is empty
stdout
Standard output is empty