Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been programming in C++ for a few years, and I've done a school project or two in C (as well as several other languages). However, I don't know C very well at all. I have a programming interview in two days, and I just realized that this interview will be in C.

How do I approach this? How do I learn C well enough to succeed in a programming interview? This job is not looking for a "C expert" or anything like that, so I think they'll be somewhat understanding if I explain that I have not programmed much in C. They just choose to host their interviews in C.

Buying and reading a textbook is not feasible, so my resources will have to be on the internet.

share|improve this question

closed as off-topic by durron597, Dan Pichelman, GlenH7, Bart van Ingen Schenau, Ixrec Apr 29 '15 at 20:13

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking career or education advice are off topic on Programmers. They are only meaningful to the asker and do not generate lasting value for the broader programming community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – durron597, Dan Pichelman, GlenH7, Bart van Ingen Schenau, Ixrec
If this question can be reworded to fit the rules in the help center, please edit the question.

I'm not really sure that this is a reasonable request - and I mean reasonable in that you can attain your goal in such a short period of time. – Nic Oct 18 '11 at 5:34
many experienced c++ developers would not consider strictly c positions. making sure you know what you are in for may be more important than the crash course. – justin Oct 18 '11 at 5:37
It's not a strictly C position. I may not even use C in the job, but they've chosen to host the interview in C. This company hosts all interviews in C. – Casey Patton Oct 18 '11 at 5:39
@CaseyPatton you should just charm the heck out of the interviewer :P – Nic Oct 18 '11 at 5:43
A day? the library! – Casey Patton Oct 18 '11 at 5:47
up vote 3 down vote accepted

Get a C compiler, write some code. You heard of C++ being C with classes? Just drop classes and templates then write a bunch of code and check if syntax works or not. You'll may want to look at actual C source to see some library calls they make since stl wont be available (but i am sure you heard of memcpy, strlen, sprintf and etc) so you probably know enough "C" as it is.

Also remember operator, function overloading does not exist along with no references.

share|improve this answer

If they're hosting the interviews in C, they want someone who knows C, not someone who can cram for a test. If you're truly serious about this, pick up a copy of K&R. (co-written by the guy who actually designed the language, may he rest in peace) I can't think of any faster way to learn C.

Alternatively, you could try this.

share|improve this answer
I am truly serious about this. The website explicitly states they don't expect all applicants know C, but that they should brush up before the interview. – Casey Patton Oct 18 '11 at 5:34
+1: Even if you cram for an interview, a seasoned interviewer can spot textbook answers vs. first-hand experience answers quite easily. – Demian Brecht Oct 18 '11 at 5:35
Agreed, and I think it's an odd choice to host the interview in a language the applicant might not know very well. I don't really have any choice but to play by the rules I've been given, however. – Casey Patton Oct 18 '11 at 5:37
They must be looking for polyglots, people who can grok new languages easily. That, or they consider C to be a "baseline" language, that everyone should at least be familiar with. – Robert Harvey Oct 18 '11 at 5:39
Yep, I think either of those are valid reasons. Unfortunately for me, I don't really have much time to learn a new language since I am in school and don't have too much free time between now and the interview (hence the question). I'll have to do my best though! – Casey Patton Oct 18 '11 at 5:40

If i was interviewing and setting an interview question in C, there would be two things I would expect to differentiate the good candidates from the bad ones.

  1. Can you design a sensible algorythm, and then write the code that reflects that design? 90% of candidates fail at this stage.
  2. Can you manage memory, think freeing memory, use pointers effectively etc..

(1) would eliminiate the no hopers from the recruitment process. (2) would diferentiate the best from the good, and would influence salary levels.

Yes, there is much more than just memory managment in C, but other C stuff such as function pointers, pedantic code writing to catch errors etc but in my experience if a programmer can understand pointers properly then they can be taught other stuff in C quickly and painlessly on the job. Trying to teach pointers to someone is a gamble. They may never grasp the concept.

share|improve this answer

The K&R book is a good recommendation. Since you did not want a book for an answer:

Convert a somewhat complex program that you wrote and understand to C. The larger and more complex, the better - it comes down to what you have available to convert, and the time you have available.

You already know the syntax, operators, etc. - just remove the features which aren't available and convert them to the C equivalent. You may have some questions, so search (and ask, if needed) at StackOverflow.

Choosing a project you wrote allows you to focus on the task, not the program.

share|improve this answer

Focus on the differences. C and C++ use the same bits & pieces, but there are some things where they differ:

  • typing discipline - C++ uses strong static typing, C has weak static typing. Consequently, you can (and often have to) cast a lot more freely in C than you would in C++.
  • different struct syntax - declaring and defining structs works differently in C than it does in C++; make sure you know how to use structs properly in C.
  • no STL - this means you have to do I/O the C way (printf and its family), as well as string handling. Be sure to know the most important libc functions for string handling and for converting between strings and numeric types.
  • malloc/free vs. new/delete - get used to using malloc and free correctly, as well as typical idioms for initializing heap-allocated structures.
  • no references - where you would pass by reference in C++, you use pass-by-pointer in C

There are more differences (such as lack of namespaces, heavy reliance on the preprocessor, encapsulation at the module level, etc.), but I doubt you're going to be programming at a scope where these are relevant.

In any case, from the job description it seems they are more interested in the algorithm part (how do you approach a particular problem) than the language part (how well do you know the syntax of language X). C is probably considered the common denominator to all programming languages, and the most likely candidate for any serious programmer to have had some exposure to.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.