Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Help in C/C++ Program in Linux

Hi all my friend needs this program if any one can give or write the program asap..its urgent .. thanks

[b]Ques[/b] Develop a C/C++ or perl program in Linux to display the following information:
1. The number of files in the current directory;
2. The total size in bytes of all the files in the current directory;
3. The number of subdirectories in the current directory.

[b]Hints[/b] for C/C++ programming:

a. The following system-defined data structures may be used:



typedef struct dirent


ino_t d_ino; /* Inode number */

off_t d_off; /* Offset next entry */

unsigned short d_reclen; /* Lengths of the name */

char d_name[1]; /* Filename */

} dirent_t;

struct stat


mode_t st_mode; /* File mode (see mknod(2)) */

ino_t st_ino; /* Inode number */

dev_t st_dev; /* ID of device containing */

/* a directory entry for this file */

dev_t st_rdev; /* ID of device */

/* This entry is defined only for */

/* char special or block special files */

nlink_t st_nlink; /* Number of links */

uid_t st_uid; /* User ID of the file's owner */

gid_t st_gid; /* Group ID of the file's group */

off_t st_size; /* File size in bytes */

time_t st_atime; /* Time of last access */

time_t st_mtime; /* Time of last data modification */

time_t st_ctime; /* Time of last file status change */

/* Times measured in seconds since */

/* 00:00:00 UTC, Jan. 1, 1970 */

long st_blksize; /* Preferred I/O block size */

blkcnt_t st_blocks; /* Number of 512 byte blocks allocated*/


b. The following API functions may be used for file/directory operations (check out their manual pages for detailed use instructions):







Sign In or Register to comment.