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 |
how to print 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 using any loop(for or while) only once(only 1 loop) and maximum 2 variables using C.
19 Answers Cap Gemini, Infosys,
Write a program using one dimensional array to assign values and then display it on the screen. Use the formula a[i]=i*10 to assign value to an element.
1 Answers Samar State University,
how to return a multiple value from a function?
String copy logic in one line.
Write a program to receive an integer and find it's octal equivalent. How can i do with using while loop.
What is wrong with the following code? int *foo() { int *s = malloc(sizeof(int)100); assert(s != NULL); return s; }
create a login program that ask username and password. if you input username or password 3 times wrong, the program will terminate else the program will prompt a message "congratulations"
main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }
String reverse with time complexity of n/2 with out using temporary variable.
#define assert(cond) if(!(cond)) \ (fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\ __FILE__,__LINE__), abort()) void main() { int i = 10; if(i==0) assert(i < 100); else printf("This statement becomes else for if in assert macro"); }
How do you sort a Linked List (singly connected) in O(n) please mail to pawan.10k@gmail.com if u can find an anser...i m desperate to knw...
6 Answers Microsoft, MSD, Oracle,
main() { static int var = 5; printf("%d ",var--); if(var) main(); }