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 |
given integer number,write a program that displays the number as follows: First line :all digits second line : all except the first digit . . . . Last line : the last digit
How do you create a really large matrix (i.e. 3500x3500) in C without having the program crash? I can only reach up to 2500. It must have something to do with lack of memory. Please help!
int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }
main() { int x=5; clrscr(); for(;x==0;x--) { printf("x=%d\n”", x--); } } a. 4, 3, 2, 1, 0 b. 1, 2, 3, 4, 5 c. 0, 1, 2, 3, 4 d. none of the above
main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); }
main() { clrscr(); } clrscr();
#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }
writte a c-programm to display smill paces
Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?
1 o 1 1 0 1 0 1 0 1 1 0 1 0 1 how to design this function format in c-language ?
main() { int i=400,j=300; printf("%d..%d"); }
write a c-program to find gcd using recursive functions