strcpy question

This is a discussion on strcpy question within the C Programming forums, part of the General Programming Boards category; I have a question about strcpy, i was wondering why did they make it work the way it works. Code: ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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

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