would like some ideas of how to acutally create my own cd function from scratch using C programming.I'm building a shell program in C.

You can't unless you also write your own file system, which I doubt you will want to do. The CD command is only good while the program is still running. After the program terminated the current directory reverts back to whatever it was before the program started. AFAIK there is no way to change that behavior.

The program you posted in another thread about this problem should work as far as I can tell. I never had a problem with chdir() unless I was giving it an invalid path.