Код: Выделить всё
#include
#define MAX 1000
int getl(char line[], int lim);
void copy(char to[], char from[]);
int main(){
int len, max;
max = 0;
char line[MAX];
char longest[MAX];
while((len = getl(line, MAX)) > 0)
if (len > max) {
max = len;
copy(longest, line);
}
if (max > 0)
printf("%s\n", longest);
return 0;
}
int getl(char line[], int lim[])
{
int c, i;
for (i = 0; (i < lim -1) && (c = getchar()) != EOF && (c != ' '; ++i))
line[i] = c;
if (c == '\n') {
line[i] = c;
++i;
}
line[i] = '\0';
return i;
}
void copy(char to[], char from[])
{
int i = 0;
while ((to[i] = from[i]) != '\0')
++i;
}
Код: Выделить всё
file.c:22:5: error: conflicting types for ‘getl’; have ‘int(char \*, int \*)’
22 | int getl(char line\[\], int lim\[\])
| ^\~\~\~
file.c:4:5: note: previous declaration of ‘getl’ with type ‘int(char \*, int)’
4 | int getl(char line\[\], int lim);
Подробнее здесь: https://stackoverflow.com/questions/790 ... ot-working
Мобильная версия