How to create a pseudo terminal

i have been trying to write a program to create a pseudo terminal..but im not familiar with pseudo terminals..so could some one help me out with the program flow ??