Hi everybody.
Im trying to make a C program
1 #include<stdio.h>
2 #define SIZE 100
3
4 int getline(char line[], int lim);
5
6 int getline(char line[], int lim) {
7 int c,i;
8
9
10 for(i=0; i<lim-1 && (c=getchar()) !="\0"; ++i)
11 line[i] = c;
12 if(c=="\n") {
13 line[i]=c;
14 ++i;
15 }
16 line[i]="\0";
17 return i;
18 }
19
20 main() {
21 char line[SIZE];
22 int c;
23 int sizeOfArray = sizeof line/sizeof(int);
24
25 while(c=getline(line, SIZE))
26 printf("%c", (for(int i=0; i<sizeOfArray; i++) line[i]));
27 }
but when I compile it it gives me this errors
serg@serg-PORTEGE-Z835:~$ gcc hw.c -o hw
hw.c:4:5: error: conflicting types for ‘getline’
/usr/include/stdio.h:671:20: note: previous declaration of ‘getline’ was here
hw.c:6:5: error: conflicting types for ‘getline’
/usr/include/stdio.h:671:20: note: previous declaration of ‘getline’ was here
hw.c: In function ‘getline’:
hw.c:10:36: warning: comparison between pointer and integer [enabled by default]
hw.c:12:7: warning: comparison between pointer and integer [enabled by default]
hw.c:16:10: warning: assignment makes integer from pointer without a cast [enabled by default]
hw.c: In function ‘main’:
hw.c:26:17: error: expected expression before ‘for’
Please help me to fix it