Thread: An interview question

  1. #1
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342

    An interview question

    Is there a way to do this :
    Write a C program, that when executed on a windows machine, it prints " MSWorld" and when executed on a unix machine , it prints "UNIX"
    In the middle of difficulty, lies opportunity

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    You could look into using preprocessor directives to detect what O/S you're compiling on, and only compile the code for that O/S. #ifdef is probably what you want.

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Not without recompiling it for the target OS as MacGyver said.

  4. #4
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    #ifndef __unix__
    #error "This section will only work on UNIX systems"
    #endif

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  3. Job Interview Coming Up
    By adamg in forum C Programming
    Replies: 5
    Last Post: 05-02-2004, 11:25 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM