Archive

Archive for September, 2012

Dream High

September 25, 2012 Leave a comment

I dream high 난 꿈을 꾸죠 힘들 때면 난 눈을 감고
I Dream High, i dream, when its hard i close my eyes
꿈이 이뤄지는 그 순간을 계속 떠올리며 일어나죠
While i imagine that moment i get up

두려움의 끝에서 난 오늘도 흔들리죠
I shake at the end of fear
떨어질까 봐 날아오르지 못하는 어린 새처럼
Afraid of falling like a baby bird who cant fly up
자꾸 내가 할 수 있나 내 꿈이 이뤄질까
Can I do it, will my dream come true
내딛는 걸음 한 걸음 걸음이 다시 두려워질 때마다
one by one my walking goes when i get afraid
I Dream High 난 꿈을 꾸죠 힘들 때면 난 눈을감고
I Dream High, I dream, when im tired i close my eyes
꿈이 이뤄지는 그 순간을 계속 떠올리먀 일어나죠
I keep imagining that dream while i get up
I can fly high 나는 믿어요 언젠간 난 저 하늘 위로
I can fly high, i belive that i can go up in that sky
날개를 펴고 누구보다도 자유롭개 높이 날아오를 거예요
Open my wings, fly freely up more then anyone

넘어진 날 일으겨 줄 용기가 필요하죠
I need courage that will stand the fallen me
먼지를 털고 다시 일어나 또 한 번 뛰어갈 용기가
I dust the dust, Courage that will stand me and jump once a again
다시 한 번 나를 믿고 나의 운명을 믿고
Belive in myself once more, Belive in my faith
모든 걸 걸고 내 키보다 높은 벽을 뛰어넘을 거예요
Bet everything, and im going to jump a wall taller then me

I dream high 난 꿈을 꾸죠 힘들 때면 난 눈을 감고
I dream high, i dream, when im tired i close my eyes
꿈이 이뤄지는 그 순간을 계속 떠올리며 (다시) 일어나죠
Imagning that my dream will come true while i (again) get up
I can fly high 나는 믿어요 언졘건 넌 저 하늘 위로
I can fly high i belive in that i will go up in that sky
날개를 펴고 누구보다도 자유롭게 높이 (난) 날아오를 거예요
Open my wings and (i’m) going to fly more freely than anyone has

Dream high a chance to fly high
Dream high a chance to fly high
아픔들은 이젠 모두다 bye bye
Bye bye to the hurts
하늘에 있는 저 별들처럼 높이 날아봐
Fly high like the stars in the sky
네 꿈들을 펼쳐 보는 거야 time for you to shine
Open your dreams, time for you to shine
이제부터 시작이야 gotta make em mine
Starting Now, gotta make em mine
네 손으로 이뤄가 미랠 두려워하지 마 인젠 힘껏 자신 있게 걸어가
Dont be afraid of the future in you hands, walk in confidance now
Destiny 숙명이지 멈출 수 없는 운명이 지금
You can’t stop destiney now
우리 눈앞에 펼쳐지지 이건 너를 위한 whole new fantasy
Whole new fantasy is open in front of your eyes
그러니 이제부터 여기 내 손을 잡아
So hold my hand now
우리의 목표는 지금부퍼 하나 꿈과 미래 포기하지 않아
Our stop is the same now, dont give up on your dreams
젊음 열정 여기 모두다 Dream High
When your young dream high everyone

I dream high 난 꿈을 꾸죠 힘들 때면 난 눈을 감고
I dream high, I dream, when im tired i close my eyes
꿈이 이뤄지는 그 순갈을 계속 떠올리며 일어나죠
Imagine the dream coming true while getting up
I can fly high 나는 믿어요 언젠간 난 저 하늘 위로
I can fly high, i belive that i can go up that sky
날개를 펴고 누구보다도 자유룹게 높이 날아오를 게예요
Open my wings and fly high freely then anyone else

Advertisements
Categories: Music

Stack and Heap

September 16, 2012 Leave a comment

When we define some class like :

class Vector3 {
public:
 float x,y,z;
 Vector3(){ x=0.0f ; y=0.0f; z=0.0f};
}

and then create some code to use it :

1. use stack allocation

Vector3 myVect;
myVect.x = 1.0f;
myVect.y = 2.0f;
myVect.z = 3.0f;

or

2. use heap allocation

Vector3 *myVect = new  Vector3;
myVect->x = 1.0f;
myVect->y = 2.0f;
myVect->z = 3.0f;

which one is better ?

we have to consider several things anyway.

  1. Using stack is faster but very very finite size
  2. Heap is slower because needed to search for available free memory
  3. If using heap,  then have to do clean up manually ( which lead to memory leak problem)
  4. Consider about variable life time
Categories: C/C++, Programming

PrototypeX

September 8, 2012 1 comment

Spending time creating prototypeX after graduated from master course and prepare for work.

i used Unity Iphone and C#

Although i could only run it on simulator, It was very interesting.

 

Categories: Programming, Unity

Using Iterator

September 7, 2012 Leave a comment

Consider if we have Different Object type but have same parent class. for example Triangle and Square are in herite Shape. you create object from those class and want to draw them on the screen.


class Shape {
protected:
Color color;
public:
virtual void draw();
}

class Triangle {
private:
Vector3 top;
Vector3 bottom_left;
Vector3 bottom_right;
public:
virtual void draw(
// draw Triangle
);
}

class Rectangle {
private:
Vector3 top_left;
Vector3 top_right;
Vector3 bottom_left;
Vector3 bottom_right;
public:
virtual void draw(
// draw Rectangle
);
}

 

we can store them into list


std::list<Shape*> my_list
std::list<Shape*>::iterator it

Shape *my_triangle = new Triangle();
Shape *my_rectangle = new Rectangle();

my_list.push_back(my_triangle);
my_list.push_back(my_rectangle);

 

Then perform iteration to draw

 

for(it=my_list.begin() ; it!= my_list.end() ; it++)
{
(*it)->draw();
}

 

Categories: C/C++

Pointer

September 3, 2012 Leave a comment

Spending weekend with Pointer.

1. Increment

#include <stdio.h> 
#include  
using namespace std; 

int main() 
{ 
 int *ptr = NULL ; 
 int i; 

 int my_array[] = { 1,2,3,4}; 
 ptr = my_array; 

 for(int i=0; i < 4; i++) 
 { 
   cout << "Address : " <<  ( ptr + i)  << " Value : " <<  *(ptr + i)  << "\n" ; 
 }  
 return 0; 
}

2. Copy String

#include <stdio.h>
char *my_strcpy(char *dst, char const *src)
{
  char *p;
  p = dst;

  while( *src != ''  )
  {
    *p++ = *src++ ;
  }

 *p = '';
 return dst;

}

int main()
{
  char strDst[80];
  char strSrc[80] = "this is string";

  my_strcpy(strDst, strSrc);
  puts(strDst);
}

3. Struct

#include <stdio.h>

struct tag {
  char first_name[30];
  char last_name[30];
  int age ;
};

char *my_strcpy(char *dst, char const *src)
{
  char *p;
  p = dst;

  while( *src != ''  )
  {
    *p++ = *src++ ;
  }

 *p = '';
 return dst;

}

void print_employee(struct tag *a)
{

  printf("-----------------------------------\n");
  printf("First Name: %s \n",  a->first_name);
  printf("Last Name: %s \n",   a->last_name);
  printf("Age: %d \n",   a->age); 
  printf("-----------------------------------\n");

}

struct tag employee;

int main()
{

  struct tag *ptr_employee;
  ptr_employee = &employee;

  my_strcpy(employee.first_name, "Tonny");
  my_strcpy(employee.last_name, "Kusdarwanto");
  ptr_employee->age = 27;   

  print_employee(ptr_employee) ; 

}

2. Dynamic Array 1D

#include <stdio.h>
#include <stdlib.h>
#define SIZE 10

int *ptr;

int main()
{
 ptr = (int *)malloc(SIZE*sizeof(int)) ;
 if(ptr == NULL)
 {
   printf("Error! \n");
   return (-1);
 }

 for(int i=0; i< SIZE ; i++) 
 {
   ptr[i] = 2;
 }

 for(int i=0; i< SIZE ; i++) 
 {
   printf("%d \n", *(ptr + i) );
 }

 return 0;
}

2. Dynamic Array 2D

#include <stdio.h>
#include <stdlib.h>

#define COLS 10

typedef int RowArray[COLS];

RowArray *ptr_array;

int main(void)
{
 int nRow = 10;
 ptr_array =  (RowArray *)  malloc( nRow * COLS * sizeof(int) );

 if (ptr_array == NULL)
 {
  printf("Error");
  return (-1);
 }

 for(int i=0;i<nRow;i++)
 {
  for(int j=0;j<COLS;j++)
  {
   ptr_array[i][j] = i*j ;
  }
 }

 for(int i=0;i<nRow;i++)
 {
  for(int j=0;j<COLS;j++)
  {
   printf("%2d ", ptr_array[i][j]) ;
  }
  printf("\n");
 }
 return 0;
}

 

Reference:

Categories: C/C++, Programming