Skip to content

Instantly share code, notes, and snippets.

View ixn's full-sized avatar

IXn Muhammad ixn

View GitHub Profile
/*
Internal Function
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/*
#include "internal_api.h"
/*
data_t berupa struct yang dienkapsulasi
dan hanya bisa digunakan pada file ini
*/
struct _data_t{
int data1;
int data2;
@ixn
ixn / penjumlahan.c
Last active January 22, 2017 00:26
Contoh sangat sederhana enkapsulasi data dengan c
/*
contoh sangat sederhana enkapsulasi data dengan c
more: https://deeprhezy.trumblr.com
compile: gcc -o penjumlahan penjumlahan.c internal_api.c
*/
#include "internal_api.h"
int
@ixn
ixn / Makefile
Created October 25, 2014 11:12
Simple object oriented in C (http://deeprhezy.tumblr.com)
CC=gcc
CFLAGS=-I.
LDFLAGS=
FUNGSIOBJ = object.c\
fungsiobj.c
all:object
@ixn
ixn / Makefile
Created October 25, 2014 11:03
Simple object oriented in C (http://deeprhezy.tumblr.com)
CC=gcc
CFLAGS=-I.
LDFLAGS=
FUNGSIOBJ = object.c\
fungsiobj.c
all:object
@ixn
ixn / fungsiobj.c
Created October 25, 2014 11:03
Simple object oriented in C (http://deeprhezy.tumblr.com)
#include "object.h"
/* Melakukan pengalokasian memory, menggunakan calloc
Saat menggunakan fungsi ini direkomendasikan untuk
menghapus kembali memory menggunakan object_free()
*/
object*
object_new(void){
@ixn
ixn / object.h
Created October 25, 2014 11:02
Simple object oriented in C (http://deeprhezy.tumblr.com)
#ifndef __OBJECT_H__
#define __OBJECT_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* membuat pengelompokan data dengan struct
kita beri nama object yang berisi (object1 & object2)
@ixn
ixn / object.c
Created October 25, 2014 11:01
Simple object oriented in C (http://deeprhezy.tumblr.com)
#include "object.h"
int
main(int argc, char* argv[])
{
/* Deklarasi obj sebagai object */
object* obj;
@ixn
ixn / hello-world.c
Last active August 29, 2015 14:07
Hello World in C use Libevent
/*
This exmple program provides a trivial server program that listens for TCP
connections on port 9995. When they arrive, it writes a short message to
each client connection, and closes each connection once it is flushed.
Where possible, it exits cleanly in response to a SIGINT (ctrl-c).
*/
/* Deklarasi lib standar yang digunakan */
#include <string.h>
CC=gcc
CFLAGS=-I.
all: server_kalkulator
server_kalkulator: server_kalkulator.c
$(CC) $(CFLAGS) -o server_kalkulator $^ -L/usr/local/lib -levent -lm $(LDFLAGS)
clean:
rm -f *.o
rm -f *~
rm -f server_kalkulator