Thread: Trouble understanding some code please help

  1. #1
    Registered User
    Join Date
    Feb 2012
    Location
    Trinidad & Tobago
    Posts
    43

    Trouble understanding some code please help

    just when i was conformable whit pointers i saw this ,

    Why does the function have an * in front it's name

    Code:
    char *my_strcpy(char  *destination , char *source)


    i thought it was a function pointer but i learned that a function pointer looks like
    Code:
    char (*my_strcpy)(char  *destination , char *source)


    so my question is basically if its not a function pointer what is it?
    and why is it there/what does it do?

    entire code:
    Code:
    char *my_strcpy(char  *destination , char *source)
    {
         char *p=destination;
         while(*sourse!='\0')
         {
               *p++=*source++;
         }
         *p='\0';
         return destination;
    }
    

  2. #2
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,883
    It tells you that the function returns a pointer to a char.

    This article has helped thousands of people make that leap from beginner to intermediate c programmers - http://untroubled.org/articles/cdecls.txt

    Spend a good few hours reading though it.
    Fact - Beethoven wrote his first symphony in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble understanding the concepts behind the code
    By curlygeek in forum C Programming
    Replies: 10
    Last Post: 10-14-2012, 04:31 AM
  2. Trouble Understanding the assignment given.
    By AlbyRang in forum C Programming
    Replies: 3
    Last Post: 03-30-2012, 01:51 AM
  3. Trouble understanding code to calculate sum of n numbers
    By jackloring in forum C Programming
    Replies: 8
    Last Post: 11-13-2010, 04:33 AM
  4. trouble understanding collision detection code
    By silk.odyssey in forum Game Programming
    Replies: 5
    Last Post: 06-16-2004, 02:27 PM
  5. a little trouble understanding
    By zema in forum C++ Programming
    Replies: 3
    Last Post: 11-05-2003, 05:49 PM