Facebook Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
0
of 0 vote

can you elaborate more !!

- TheDewarist June 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Please elalaborate more!!!!

dir * just print contents (dir/files) in current directory...
if it is the case then .... its too easy ...
use this link:

int getdir (string dir, vector<string> &files)
{
    DIR *dp;
    struct dirent *dirp;
    if((dp  = opendir(dir.c_str())) == NULL) {
        cout << "Error(" << errno << ") opening " << dir << endl;
        return errno;
    }

    while ((dirp = readdir(dp)) != NULL) {
        files.push_back(string(dirp->d_name));
    }
    closedir(dp);
    return 0;

}

- Bharat Arya June 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <dirent.h>
#include <string>
#include <string.h>
#include <iostream>
using namespace std;

int main(){
DIR *parentdir;
string dirname = "/home/prajyoti/Documents/Placement/careercup/directi";
struct dirent *fileentry ;
if((parentdir = opendir(dirname.c_str()))){
while((fileentry = readdir(parentdir)) != NULL){
if(strcmp(fileentry->d_name, ".") != 0 && strcmp(fileentry->d_name, "..")!= 0){
cout << fileentry -> d_name << endl;
}
}

}
return 0;
}

- Anonymous June 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hmm, alot is missing from the above 'solutions': where's the volume name, serial number, dir name, dir or file, date / time created, num files / dir's and their byte sizes!?!?!?

I guess you need to discover exactly what dir * does / returns and not make assumptions about what you think it returns!

- Pete June 20, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More