How to read a directory in a C program?
Answers were Sorted based on User's Feedback
Answer / lakshmi sreekanth
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
main()
{
struct dirent *dp;
DIR *dfd = opendir("/home/sreekanth");
if(dfd != NULL)
{
while((dp = readdir(dfd)) != NULL)
printf("%s\n", dp->d_name);
closedir(dfd);
}
return 0;
}
Is This Answer Correct ? | 14 Yes | 4 No |
Answer / muthu
please write the correct program with output...
by prof.muthu m.c.a phd etc..
ph:9962940220
Is This Answer Correct ? | 6 Yes | 4 No |
Answer / rakesh
void main()
{
char path[100];
cout<<"Enter the path of directory::";
cin.getline(path,100);
system("cd path");
system("dir");
} // In windows
// For linux change dir to ls.
Is This Answer Correct ? | 10 Yes | 15 No |
Answer / prince
main()
{
char path[100];
printf("Enter the path of directory:");
scanf("%s",path);
system("cd path");
system("ls");
}
Is This Answer Correct ? | 2 Yes | 20 No |
write a program in c to merge two array
struct aaa{ struct aaa *prev; int i; struct aaa *next; }; main() { struct aaa abc,def,ghi,jkl; int x=100; abc.i=0;abc.prev=&jkl; abc.next=&def; def.i=1;def.prev=&abc;def.next=&ghi; ghi.i=2;ghi.prev=&def; ghi.next=&jkl; jkl.i=3;jkl.prev=&ghi;jkl.next=&abc; x=abc.next->next->prev->next->i; printf("%d",x); }
const int perplexed = 2; #define perplexed 3 main() { #ifdef perplexed #undef perplexed #define perplexed 4 #endif printf("%d",perplexed); } a. 0 b. 2 c. 4 d. none of the above
what is the output of the below program & why ? #include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); }
main() { int i = 100; clrscr(); printf("%d", sizeof(sizeof(i))); } a. 2 b. 100 c. 4 d. none of the above
why java is platform independent?
How to count a sum, when the numbers are read from stdin and stored into a structure?
How we print the table of 2 using for loop in c programing?
find A^B using Recursive function
Display the time of the system and display the right time of the other country
Declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
WAP to display 1,2,3,4,5........N