Thread: Increment simple question

  1. #1
    Registered User
    Join Date
    Mar 2008
    Location
    France
    Posts
    9

    Increment simple question

    Is it safe to say that :

    Code:
                *curr=*scan;
                curr++;
                scan++;
    equals
    Code:
                *curr++=*scan++;
    ?

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    Note that some people may find this syntax hard to read and you would be better with something like

    Code:
    *curr = 1 + *scan++;
    I hate real numbers.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    ? That wouldn't do the same thing. (The pointer curr wouldn't move, for starters.)

  5. #5
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    Oh damn, it's right, my mistake. I forgot the * and ++ operator were associative from right to left. But it's still a bit of a hazardous syntax.
    I hate real numbers.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by foxman View Post
    But it's still a bit of a hazardous syntax.
    Not really...
    I think it also may be somewhat commonly used, though I can't be sure.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    May 2008
    Posts
    53
    Quote Originally Posted by Elysia View Post
    I think it also may be somewhat commonly used, though I can't be sure.
    I would definitely think so (but perhaps you were posting tongue-in-cheek). It is standard idiom in C when copying stuff over.

    --
    Computer Programming: An Introduction for the Scientifically Inclined

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple simple design question
    By Chaplin27 in forum C++ Programming
    Replies: 6
    Last Post: 05-31-2005, 11:33 PM
  2. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  3. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  4. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  5. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM