Ver Mensaje Individual
  #3 (permalink)  
Antiguo 02/11/2010, 11:13
luface2000
 
Fecha de Ingreso: octubre-2006
Mensajes: 169
Antigüedad: 17 años, 7 meses
Puntos: 2
Respuesta: Error en programa

Hola,

he realizado las modificaciones y me sigue dando el mismo error. La verdad es que estoy perdido. Adjunto imagen de eclipse y el error mostrado http://www.flickr.com/photos/34532364@N02/5139743603/

Un saludo y gracias.



Código:
#include <stdio.h>
#define MAXLINE 1000            /*Tamaño máximo de la línea de entrada*/

//int getline(char line[], int maxline);
int getline(char s[], int lim);
void copy(char to[], char from[]);

/*Imprime la línea más larga*/
main()
{
        int len;                                /*longitud actual de la línea*/
        int max;                                /*máxima longitud vista hasta el momento*/
        char line[MAXLINE];             /*Línea de entrada actual*/
        char longest[MAXLINE];  /*Línea más larga se guarda aquí*/

        max = 0;
        while((len = getline(line, MAXLINE)) > 0)
                if(len > max)
                {
                        max = len;
                        copy(longest, line);
                }
        if(max > 0)
                printf("%s", longest);
        return 0;
}

int getline(char s[], int lim)
{
        int c, i;
        for(i=0; i<lim-1 && (c=getchar()) != EOF && c!='\n'; ++i)
                s[i] = c;
        if(c=='\n')
        {
                s[i]=c;
                ++i;
        }
        s[i] = '\0';
        return i;
}

void copy(char to[], char from[])
{
        int i;
        i=0;
        while((to[i] = from[i])!='\0')
                ++i;
}