ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  C Code
 
 


 

 
 C Code interview questions  C Code Interview Questions
 C++ Code interview questions  C++ Code Interview Questions
 VC++ Code interview questions  VC++ Code Interview Questions
 Java Code interview questions  Java Code Interview Questions
 Dot Net Code interview questions  Dot Net Code Interview Questions
 Visual Basic Code interview questions  Visual Basic Code Interview Questions
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions
Question
How to read a directory in a C program?
 Question Submitted By :: Solidcube
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How to read a directory in a C program?
Answer
# 1
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 ?    4 Yes 7 No
Rakesh
 
  Re: How to read a directory in a C program?
Answer
# 2
main()
{
	char path[100];
	printf("Enter the path of directory:");
	scanf("%s",path);
	system("cd path");
	system("ls");
}
 
Is This Answer Correct ?    1 Yes 10 No
Prince
 
 
 
  Re: How to read a directory in a C program?
Answer
# 3
please write the correct program with output...
 
                               by prof.muthu m.c.a phd etc..
                               ph:9962940220
 
Is This Answer Correct ?    2 Yes 3 No
Muthu
 
  Re: How to read a directory in a C program?
Answer
# 4
#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 ?    2 Yes 1 No
Lakshmi Sreekanth
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
char *someFun1() { char temp[ ] = “string"; return temp; } char *someFun2() { char temp[ ] = {‘s’, ‘t’,’r’,’i’,’n’,’g’}; return temp; } int main() { puts(someFun1()); puts(someFun2()); }  1
print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!  7
void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit=--giveit); }  1
main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024 HCL1
void main() { if(~0 == (unsigned int)-1) printf(“You can answer this if you know how values are represented in memory”); }  1
What is the output of the program given below main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }  1
char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? 1) gets(inputString) 2) fgets(inputString, sizeof(inputString), fp)  1
#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }  1
#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }  1
main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcpy(a,b)); } a. “Hello” b. “Hello World” c. “HelloWorld” d. None of the above HCL1
main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *++ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); ++*ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); }  1
main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit >> (i - (i -1))); } } a. 512, 256, 0, 0, 0 b. 256, 256, 0, 0, 0 c. 512, 512, 512, 512, 512 d. 256, 256, 256, 256, 256 HCL1
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }  1
main() { char *p = “ayqm”; printf(“%c”,++*(p++)); } TCS2
How to access command-line arguments?  4
write a program in c to merge two array  1
main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }  1
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }  1
main() { char a[4]="HELL"; printf("%s",a); } Wipro1
how to check whether a linked list is circular.  3
 
For more C Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com