- 1
How can i include a library to my code
How can i include a library Ex : #include <cs50.h> Tip: i am using a android -mobile-
13 Respuestas
+ 1
my best bet is to install a compiler and put the h file in its include folder so you can run it locally, but I don't know how it works for android.
I'd rather just set it aside for now and work on something else
+ 1
if you want to use cs50 helpers like string type you have to download the .c and .h files from https://github.com/cs50/libcs50/tree/main/src and put them at the front of your file to use in the sandbox. I wouldn't suggest it as cs50 (though a great course and great helper files) will confuse new programmers learning C because there are no types like string (someone will mention literal string here) in C.
+ 1
Ti Get V2 you have to download the whole .c and .h files and put them in your .c file to use it in the sandbox. I would recommend forgetting cs50.h and see how you can implement standard C functions.
Do a simple exercise:
Take user input of a name no more the 25 char long.
Output "Hello user."
Without using cs50.h
+ 1
#include<stdlib.h>
+ 1
You can easily include libraries by #include<> preprocessor ,
Just put lib name inside it
#include <stdio.h>
If you want include a lib that there is in a special folder or which folder that current file is use ""
#include "test.h"
NOTE:
If you use android you can use termux https://play.google.com/store/apps/details?id=com.termux
Install gcc or cc , compile and run it
Or you can use c4droid , it's great
https://play.google.com/store/apps/details?id=com.n0n3m4.droidc
0
If you have a local file you want to include, you have to use quotation marks if you want to include it. If cs50.h is a file you made that's in the same location as your main file, you use the statement:
#include "cs50.h"
If you use angle brackets <> it is implied that the file is in the standard library or at least in the same location, like stdio.h or stdlib.h
If cs50.h is supposed to be in angle brackets, you have to download it and put it in the same folder where the other standard library files are. I don't think you can install it in sololearn though
0
I don't have that library + i am using sololearn sandbox to code
0
I use
#include "cs50.c"
The output is :
"There is no file by this name was found" something like that
0
How can i do that
Don't i need (get_string) to do that
0
I am still at week 3 at CS50 course
0
i think he's saying to copy and paste the contents of the .h file and put it in your code so you would have the functions without having to use an include statements
0
The Harvard cs50 is great and the professors lectures are on point. The helper functions in the cs50 .c and .h files skew the C learning for new C programers with functions like get_string() because the new user has no understanding of char * or char[]. Here is a great book. Read it and do the exercises. You will learn C (not the most current) then take cs50. You will rock the course then. Also think about this the latter weeks of cs50 you will do your exercises in other languages. C will give you the most fundamental basics of structure, conditionals, loops, types, data structures etc. to be able to tackel any language.
https://kremlin.cc/k&r.pdf
0
Thanks man i appreciate it ❣️