Skip to content

Instantly share code, notes, and snippets.

View bzdgn's full-sized avatar
🏠
Working from home

Levent Divilioglu bzdgn

🏠
Working from home
View GitHub Profile
@bzdgn
bzdgn / killmem.c
Created November 10, 2015 13:13
Memory Exhaust
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define BLOCK 1024*1024*1024
int main()
{
void * p1 = 0;
void * p2 = 0;
void * p3 = 0;
@bzdgn
bzdgn / FileIOSample.c
Last active November 10, 2015 12:32
File IO Sample with fprintf [writing ~1GB of data into text file]
#include <stdio.h>
#include <string.h>
#include <windows.h>
long diff_micro(LARGE_INTEGER *start, LARGE_INTEGER *end)
{
LARGE_INTEGER Frequency, elapsed;
QueryPerformanceFrequency(&Frequency);
elapsed.QuadPart = end->QuadPart - start->QuadPart;
@bzdgn
bzdgn / SprintfBuffer.c
Created November 10, 2015 09:34
Sprintf and Buffer Sample
#include <stdio.h>
#define BUFFER_SIZE 100
int main()
{
char * font = "Myriad Pro";
int size = 32;
char * message = "Hello world";
@bzdgn
bzdgn / BasicPrintfDemo.c
Last active November 10, 2015 08:18
Basic printf Functionality Sample
#include <stdio.h>
int main()
{
printf("****************************************************\n");
printf("\n");
printf("64-bit Decimal : %I64d\n", 111222333444);
printf("64-bit Hexadecimal: %I64x\n", 111222333444);
printf("64-bit Hex Big : %I64X\n", 111222333444);
printf("64-bit Hex 2 : 0x%I64X\n", 111222333444);
@bzdgn
bzdgn / VoidPointers.c
Created November 10, 2015 07:49
Void Pointers & Malloc & Free Sample
#include <stdio.h>
#include <stdlib.h> /* for malloc function */
#include <string.h> /* memcpy */
int main()
{
void *p = malloc(4); /* 4 bytes requested */
if(!p)
{
@bzdgn
bzdgn / PointersToPointers.c
Last active November 9, 2015 23:24
Pointer to Pointers Sample & Out Parameter Sample
#include <stdio.h>
/********************************************
* Function : MinMax *
* Input parameters : *begin, *end *
* Output parameters: **smallest, **largest *
********************************************/
int minMax(int * begin,
int * end,
int ** smallest,
#include <stdio.h>
int getStringLength1(char array[])
{
if(array)
{
int length = 0;
for(char *p = array; *p != 0; ++p)
{
++length;
@bzdgn
bzdgn / Arrays.c
Last active November 9, 2015 20:33
C Array Sample
#include <stdio.h>
void Print(int * begin, int * end)
{
for(; begin != end; ++begin)
{
printf("%d\n", *begin);
}
}
@bzdgn
bzdgn / PointerSample.c
Last active November 9, 2015 15:11
C Pointer Sample
#include <stdio.h>
int main()
{
/* a simple integer */
int i = 1234;
/* a pointer to an integer */
int * p = 0;
p = &i;
@bzdgn
bzdgn / ConstPointer.cpp
Last active November 3, 2015 11:10
Const Pointer Demo and Notes
// Const.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
class Person
{
private: