C Readline Function Not Working -


i'm reading bignerdranch book on objective-c , it's running me through how take lines stdin in regular c. reason, example code that's supposed run readline duplicating input (small bug) not functioning. builds after taking input in if type mikey displays mmiikkeeyy,

i get:

(lldb) implicit declaration of function readline thread1:exc_bad_access(code=1,address=0x20000) 

code:

#include <stdio.h>  int main(int argc, const char * argv[]) {     printf("who cool? ");     const char *name = readline(null);     printf("%s cool!\n\n", name);     return 0; } 

any appreciated.

you did not include header file readline() declared. therefore compiler assumes function returns int. reason crash @ runtime.

if use gnu readline library add

#include <readline/readline.h> #include <readline/history.h> 

to code. question assume compiling xcode on os x. os x has "libedit" library has "readline wrapper". in case include

#include <editline/readline.h> 

the duplicate input (mmiikkeeyy) problem of debugger console. should work correctly if start program command line.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -