Hello everyone.
I am new to C programming and I am following the O'Reilly book called Practical C 3rd Edition.
I was trying to write a problem that reads a line from the keyboard and reports its length. I am writing my code based on what I have learned in the chapter. Below is the following code I used to do what I mentioned above:
When I try to build the program with cc I get the following error:Code:// // length.c // // // Created by Manuel Velez on 2/10/12. // Copyright (c) 2012 AEVTech. All rights reserved. // #include <stdio.h> #include <string.h> char line[100]; // Line we are looking at int main() { printf("Enter a line: "); fget(line, sizeof(line), stdin); printf("The length of the line is: %d\n", strlen(line)); return (0); }
I'm not too sure where to go from here. I went back to the chapter and read everything again but I'm just not seeing what I did wrong. I would be thankful for any help possible even if it's just sending me the right way to begin finding why I'm getting this error. Thank you to everyone in advanced!Code:Manuel-Velezs-MacBook-Pro:c_files Manolo$ cc -g -o length length.c length.c: In function ‘main’: length.c:20: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘size_t’ length.c:20: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘size_t’ Undefined symbols for architecture x86_64: "_fget", referenced from: _main in ccyXoU0g.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status



LinkBack URL
About LinkBacks



