An interview question

This is a discussion on An interview question within the C Programming forums, part of the General Programming Boards category; Is there a way to do this : Write a C program, that when executed on a windows machine, it ...

  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,211
    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, 01:14 PM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 01:52 PM
  3. Job Interview Coming Up
    By adamg in forum C Programming
    Replies: 5
    Last Post: 05-03-2004, 12:25 AM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21