Thread: Trying to sort numbers from lowest to highest

  1. #16
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by jw232 View Post
    Hmm it still worked anyways.
    Then either you didn't need that header, or you were actually using forward slashes instead of backslashes.

  2. #17
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Some compilers don't require backslashes to be escaped in preprocessor directives. VC++ 7.1 for example allows that include and will succesfully find the file.

  3. #18
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Daved View Post
    Some compilers don't require backslashes to be escaped in preprocessor directives. VC++ 7.1 for example allows that include and will succesfully find the file.
    Is that a non-standard extension? What if you actually want to use an escape code?

  4. #19
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    I'm not sure about the standard-ness of it, or how effective it is with other escape sequences, I just wanted to point out that when it comes to preprocessor directives the rules are a little different.

    In this case using double backslashes does work as well, but I don't know if that's because they're parsed as a single backslash or because a double backslash in a path has the same effect as a single one.

  5. #20
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by cpjust View Post
    Is that a non-standard extension? What if you actually want to use an escape code?
    And how many of your file-names contain newline, bel, backspace or some other "escape" character? In fact, I'm pretty sure all of those are not allowed (in Windows, Linux/Unix allows all sort of "weird" filenames, including those containing just about ANY printable or non-printable characters).

    It makes sense that the rules are actually different. The C preprocessor is responsible for replacing the #include "blah.h" wiht the content of blah.h - the compiler is responsible for replacing backslash-quoted characters in strings with the relevant binary. They have no need to follow same or similar rules.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #21
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by matsp View Post
    And how many of your file-names contain newline, bel, backspace or some other "escape" character? In fact, I'm pretty sure all of those are not allowed (in Windows, Linux/Unix allows all sort of "weird" filenames, including those containing just about ANY printable or non-printable characters).

    It makes sense that the rules are actually different. The C preprocessor is responsible for replacing the #include "blah.h" wiht the content of blah.h - the compiler is responsible for replacing backslash-quoted characters in strings with the relevant binary. They have no need to follow same or similar rules.

    --
    Mats
    Well for filenames, sure, but what about for #define?

  7. #22
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    But when you #define somename "some string", the C preprocessor will just replace every occurance of somename with "some string" - so the compiler proper doesn't even know it was a #define, but the preprocessor doesn't do anything with the string itself.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extracting lowest and highest score from array
    By sjalesho in forum C Programming
    Replies: 6
    Last Post: 03-01-2011, 06:24 PM
  2. Displaying highest and lowest values
    By beastofhonor in forum C++ Programming
    Replies: 3
    Last Post: 10-29-2006, 08:24 PM
  3. threaded merge sort
    By AusTex in forum Linux Programming
    Replies: 4
    Last Post: 05-04-2005, 04:03 AM
  4. Help On A Quick Sort Program
    By nick4 in forum C++ Programming
    Replies: 11
    Last Post: 12-06-2004, 10:51 AM
  5. interpolation sort
    By saigonara in forum C Programming
    Replies: 5
    Last Post: 07-14-2002, 06:58 PM