I am trying to work with my getline () function right now. I have a code from the book and it looks like it, but I can not do it to compile it. This is homework but this part should be copied from book only.
#include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; # Include & lt; Math.h> // Error List #define ENDOFFILE = -1; # DEFINE TOOMANYNUMS = -2; # Defined LIMIT = 256; // Announcements declaration int get_line (char line [], int); // main main () {four lines [255]; Integer number [6]; Printf ("Please input number% c:", line); Get_line (line, border); } // function int get_line (char s [], int lim) {int c, i; (I = 0; i & lt; lim-1 & amp; (C = getchar ())! = EOF & amp; c! = '\ N'; ++ i) S [i] = C; If (C == '\ n') {s [i] = c; ++ i; } S [i] = '\ 0'; Return i;
Now (edited at 10:22) I get only one error:
18 - Expected expression before being equal
The problem appears that the system on which you are compiling it, it appears that getline ()
The function is already defined, and your definition is contradictory, it appears that the C library used on Linux, in glibc, declared in stdio.h
There is a non-standard function. It should not be defined unless you include a line like #define _GNU_SOURCE
to opt-out to include no standard work, but it may be compiled by you Based on the pre-determined code.
The easiest solution is to rename your function, but you can also try your compiler options and why the GNU extensions are running.
Now that you have edited your code, your second problem is that your #define
lines are incorrect; you do not need a single or a semicolon; Processed by them, which has a different syntax than C, and you just have to type #define NAME VALUE
.
The appropriate syntax will be:
#define ENDOFFILE -1 # DEOFINE TOOMANYNUMS # 2 define LIMIT 256
Comments
Post a Comment