libcs50
libcs50 copied to clipboard
Running cs50 in coderunner 4
I installed cs50 following the instructions and can't get the function "get_string" or "get_char" to work. I am trying to run cs50 on an external app, in this case coderunner 4
this is what im trying to run
`#include <cs50.h> #include <stdio.h>
int main(void) { string first= get_string("whats your first name"); string last= get_string("whats your last name"); printf("hello, %s %s\n", first, last); }`
and I get this
LLVM ERROR: Program used external function '_get_string' which could not be resolved!
Did you compiled you .c file along with cs50.c ( note the .c) . the cs50.h just contains the prototype of cs50.c file, so that when your compiler compiles the your_code.c file , it can verify the function call matches to the included cs50.h file so that you don't make mistake and call one less , one more or pass in wrong argument.
The linker job is to link those function call to definition of function in cs50.c because your project only includes your_code.c file , compiler worked but the linked did not.
Google how to compile two or more c files in whatever you using.
for me who just uses terminal , i do this -- g++ your_code.c cs50.c
the cs50.c and your_code.c needs to be in same directory or absolute path needs to be mentioned.
You can try it. $clang your_code.c -lcs50 And delete ` befor #include <cs50.h>.