All about programming in GNU/LINUX

Getcwd Linux system Call

#include<unistd.h>

#include<stdio.h>

int main()
{
    char *buf;
    buf=malloc(30*sizeof(int));
    buf=getcwd(buf,120);//getcwd is the system call which writes the current path into the string
    /*the second argument to the call is the no.of.bytes available in the string ,
    which indicates the max.no.of.bytes hat is to be written into the string */
    printf(“\nThe current working directory is :%s “,buf);
    return 0;

}

Advertisements

One response

  1. good one 😉

    December 1, 2011 at 1:46 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s