- Function prototype declaration. Like declaring a variable in java, you can also declare a function. It is useful if you are going to call the function before the definition of the function.
- C has pointer operator.
- C doesn't have a string data type. Instead we can use char array.
- Structure is a custom data type. It's kind of an "object".
"%lf"to format double"%.2f"to format float with 2 digit after a comma."%d"to format an integer.- Store only positiv integer value:
unsigned int a; int A[4], printf("%d\n", A);will return the base address (Address of first element)int A[4]; A[0] = 3; printf("%d\n", A*);will return the value of the first element.- Casting an Array to a pointer, now you can access the element without brackets
Showing posts with label C++. Show all posts
Showing posts with label C++. Show all posts
17 October 2017
Important features and of C programming language
10 October 2017
Creating own library in C
To create your own library in C please follow this steps:
- Create two folders, name the first folder 'utils' and the second folder 'headers'
- Write your functions in a
.cfile and put it in the utils folder. - Create a
.hfile with the same name as the.cfile that contains the functions. Put the header files in the headers folder. The.hfile should contains following code. - Open terminal and go to the utils folder and compile the .c files using this command
gcc -c *.c - Build the library by putting all the .o files in an archive using this command
ar -cvq yourlibraryname.a *.olibrary name starts with lib, and don't froget the .a extension at the end - Now you can use the library in your program by adding a file header
#include "headers/yourLibraryName.h" - Compile your program by providing the library name
gcc -o programName programSourceCode.c utils/libraryName.a - If youre using C-Lion IDE, you can simply add your
.cand.hpaths to the CMakeList.txt like this:
Subscribe to:
Posts (Atom)