If you'd like to go level up
chdir("..");
will do the work. But if you'd like to have behaviour like cd -
then you should use this code:
char *prev;
prev = getcwd(prev, 0); /*POSIX.1-2001: will malloc enough memory*/
/*fail if prev is NULL, do something*/
chdir(prev);
free(prev);