Thread: Please mark my answers

  1. #1
    Registered User
    Join Date
    Feb 2011

    Please mark my answers

    Hi, everyone. I'm self-teaching C and I want to post my answers to the questions in my book so that you can correct me. Please peruse my answers and tell me what you think.

    1. Does your compiler do both the linking and compiling with just one command, or do you have to enter separate commands?

    My compilers (gcc and clang) each do compiling then linking with one command.

    2. What extension should you use for your C source files?


    3. Is FILENAME.TXT a valid name for a source file?

    Yes, but it is against convention and doesn't describe its content, so it's a bad choice of filename.

    4. If you execute a program that you have compiled and it doesn't work as you expected, what should you do?

    Figure out where the bug is - which might involve simply reading the code and conducting a thought experiment, or might involve more complicated debugging techniques. Then edit the source code, recompile and retest.

    5. What is machine language?

    It is the set of instructions that the CPU of the computer executes. It is specific to a CPU architecture (whereas C is portable). Executable files typically contain machine language.

    6. What does the linker do?

    It converts object code into an executable. It allows me to combine multiple source files into one big program.

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    London, United Kingdom
    Sounds reasonable, although a lot of times the "thought" experiment may involve actual pencils and paper.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  3. #3
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    The linker answer can be a little improved, I think, by writing it in a more technical language, thus explaining what the 'link' in linker means

  4. #4
    Registered User
    Join Date
    Feb 2011

    Linker answer

    Quote Originally Posted by manasij7479 View Post
    The linker answer can be a little improved, I think, by writing it in a more technical language, thus explaining what the 'link' in linker means
    What about this?

    A linker is a computer program that takes one or more object files and creates an executable program. These object files might represent the output of the compiler from translation units that I have created, or they might contain library functions written by someone else, or they might contain data.

    The linker allows me to combine my translation units with those written by others, allows those others to hide their source code from me, and allows me to use multiple translation units to make my source code manageable.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can't mark threads as SOLVED
    By FernandoBasso in forum General Discussions
    Replies: 7
    Last Post: 12-02-2011, 12:46 PM
  2. Usage of a Question Mark
    By thetinman in forum C++ Programming
    Replies: 8
    Last Post: 10-01-2008, 01:08 PM
  3. How do reading functions mark an end?
    By albert3721 in forum C Programming
    Replies: 11
    Last Post: 05-13-2007, 08:03 AM
  4. Let the OP mark a thread solved
    By siavoshkc in forum A Brief History of
    Replies: 20
    Last Post: 07-20-2006, 12:16 PM
  5. check mark in menu
    By willc0de4food in forum Windows Programming
    Replies: 7
    Last Post: 08-08-2005, 07:03 AM

Tags for this Thread