- 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
17 October 2017
Important features and of C programming language
13 October 2017
12 October 2017
32 Bit & 64 Bit floating number
single precision
double precision
Source: Wikipedia
Please watch this video for better understanding
11 October 2017
Angular 4, create your own custom binding
Sometimes, you want to create your own data binding, for example to use the same properties in different components to support modular programming. If you're unfamiliar with binding and component in Angular, please check my previous post about Angular. We use data binding to bind the html file to the business logic on the typescript file. But instead of using any existing properties of the html tag like
[src]=""
or [(ngModel)]= ""
we can create our own. - create a new sub-component. You can create it manually or using cli command:
ng g c yourComponent --spec false
. Now you can use the<app-yourComponent>
tag in your app-component.html - In the sub-component create an object you want to bind for e.g user
- Add
@Input()
decorator before the object declaration - your HTML file will look like this when binding element object(in serverComponent) and serverElements array(in app.component)
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
.c
file and put it in the utils folder. - Create a
.h
file with the same name as the.c
file that contains the functions. Put the header files in the headers folder. The.h
file 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 *.o
library 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
.c
and.h
paths to the CMakeList.txt like this:
3 October 2017
Angular basic knowledges, installing, adding bootstrap, and two ways data binding
- Untuk memulai menggunakan framework Angular, kamu harus menginstall node terlebih dahulu. Pergi ke Node browser, lalu ikuti instruksi untuk mendownload node.js
- Setelah itu pergi ke terminal, lalu ketik
npm install -g @angular/cli
untuk menginstall angular command line interface. kunjungi websitenya untuk mendapatkan informasi lebih lanjut Angular CLI - untuk memulai suatu project ketik
ng new <yourappname>
- lalu masuk ke folder applikasi kamu dengan mengetik
cd <yourappname>
- lalu jalankan applikasi kamu dengan mengetik
ng serve
cek applikasi kamu dengan membuka browser dan ketiklocalhost:4200
- Untuk menambahkan bootstrap, caranya install bootstrap melalui npm
npm install bootstrap --save
lalu buka folder .angular-cli.json dan tambahkan di bagian "styles""../node_modules/bootstrap/dist/css/bootstrap.min.css"
- Data binding satu arah dari HTML ke Business logic biasanya dilakukan menggunakan event handling
<button (click) = "YourMethod()">
atau<input type="text" (input) = "YourMethod($event)">
- Sebaliknya, data binding satu arah dari Business logic ke HTML biasanya dilakukan menggunakan property binding
<button [disabled]="sex === 'male'">
- Untuk melakukan komunikasi dua arah antara typescript(Business Logic) dan Template(HTML) kita bisa mengunakan data binding dua arah
<input type="text" [(ngModel)] = "data">
Subscribe to:
Posts (Atom)