I am trying to use getline in C with codeblocks and I am having trouble getting it to run on my machine. The code works on a server I have access too but I have limited wifi access so I need this to work on my machine. I am running windows 8.1 64 bit and codeblocks 13.12 with the gcc compiler.
here is the one of the three sections of code that uses getline, with some of the extra variables removed.
#include <stdio.h>
#include <stdlib.h> // For error exit()
#include <string.h>
char *cmd_buffer = NULL;
size_t cmd_buffer_len = 0, bytes_read = 0;
size_t words_read; // number of items read by sscanf call
bytes_read = getline(&cmd_buffer, &cmd_buffer_len, stdin);
if (bytes_read == -1) {
done = 1; // Hit end of file
}
the error is very simply:
undefined reference to 'getline'
How can I get this to work?
EDIT I added the headers. I also want to mention that I saw a few posts on this site that did not work for me.
Perhaps this work.