Adobe Interview Question for Software Engineer / Developers






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

int main()
{
FILE* file = fopen(__FILE__,"r");

char ch;
while((ch=fgetc(file))!=EOF)
{
putchar(ch);
}

return 0;
}

- light April 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

__FILE__ is a preprocessor macro that expands to full path to the current file.

- Psycho October 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

in C/C++ open file in argv[0] and read through and print

- Sharat February 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think using __FILE__ is more robust because the executable might not have the same name as the source file. We are assuming that the executable is in the same directory as the source file though.

- renctan February 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can you please elaborate on this?

- cirus February 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

This comment has been deleted.

- Administrator February 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Apparently it would stop them from hiring an asshole like you, so it must have some merit.

- Anonymous February 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

sharat the question says that no input is provided so i doubt the use of command line arguments.

Well, i dont understand wht is logic behind asking such a problem .

One can simply read the same file and print it character by character.

Here is the code

#include <stdio.h>
int main()
{
FILE *fp;
char ch;
system("clear");

if ( (fp = fopen("adobe.c", "r")) == NULL )
{
printf ("error opening the file");
return 0;
}
while ( (ch = fgetc(fp)) != EOF )
{
putchar(ch);
}
}

Ok i wrote the code with an assumption that the name of the file shall be same as adobe.c
but i see the catch being that name shall be recieved as argument which is not allowed.

A little bit of googling gave me this
main(){char q=34, n=10,*a="main() {char q=34,n=10,*a=%c%s%c; printf(a,q,a,q,n);}%c";printf(a,q,a,q,n);}

Can somebody comment is this is what they are looking for.

- hary February 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes, that's what they're looking for. It's not a great interview question, since you either know the trick or you don't.

- Anonymous February 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

A quine is a computer program which produces a copy of its own source code as its only output.

- Anonymous February 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Ok, thats good input. To add it further i will add the link which gives the C quine.

//ww.nyx.net/~gthompso/quine.htm//

almost similar to what i found on some other link.

- hary February 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
int main(void){char n='\n';char b='\\';char q='"';char*p="#include <stdio.h>%cint main(void){char n='%cn';char b='%c%c';char q='%c';char*p=%c%s%c;printf(p,n,b,b,b,q,q,p,q,n);return 0;}%c";printf(p,n,b,b,b,q,q,p,q,n);return 0;}

The above is a wonderful eg of of a quine

- codebreaker :P September 15, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

in the first code
replace "adobe.c" by __FILE__ l make program generalized. and renaming code will not affect the functionality
Ex : FILE *fp = fopen(__FILE__,"r");
Verified on (ubuntu 9.10, x86 arch) \

- Anubhav February 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char*s="char*s=%c%s%c;main(){printf(s,34,s,34);}";main(){printf(s,34,s,34);}

- fabregas March 05, 2011 | 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