Thread: strcpy question

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    494

    strcpy question

    I have a question about strcpy, i was wondering why did they make it work the way it works.

    Code:
    char *strcpy(char *dest, const char *src);
    wouldnt it make more sense if it was

    Code:
    char *strcpy(char *src, const char *dest);
    I mean when we think of moving something, we always say from A to b, instead of b from A.
    When no one helps you out. Call google();

  2. #2
    Registered User
    Join Date
    Jun 2003
    Location
    Austria
    Posts
    55
    maybe they did so, because in assembler the dest also stands on the left side?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Assignments are right-to-left as well.

    a = 2;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by IceBall
    maybe they did so, because in assembler the dest also stands on the left side?
    It depends on which syntax you are using.

    Intel syntax is dest src
    but AT&T syntax is src dest

    I have a question about strcpy, i was wondering why did they make it work the way it works.
    Why is there a unary + operator?
    Why is assignment right to left?
    Answers: Because the guys who wrote the language are mathematicians.

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. Strcpy
    By Godders_2k in forum C Programming
    Replies: 17
    Last Post: 12-12-2007, 12:34 PM
  3. strcpy question
    By cman9999 in forum C Programming
    Replies: 9
    Last Post: 03-07-2003, 02:03 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. strcpy
    By Luigi in forum C++ Programming
    Replies: 17
    Last Post: 02-16-2003, 04:11 PM