Thread: variable addresses and pointers

  1. #31
    1 == 1 tzpb8's Avatar
    Join Date
    Jul 2006
    Posts
    36
    function pointer is: datatype (* name) (parameter types)
    array pointer is simply: datatype (* name) []
    Right? or can i write it in another way without parenthesis? so i can figure out how it works better
    Last edited by tzpb8; 07-26-2006 at 01:22 PM.

  2. #32
    1 == 1 tzpb8's Avatar
    Join Date
    Jul 2006
    Posts
    36
    Oooh but when you say name is a type you make me think it's either int char or float etc, what i meant with name is the name of the pointer itself. You mean that name is an array? when you say name is an array type.. think i get it now then
    Hmm the name array has three elements of function pointers with assigned parameters..
    Before you edited your post you had (* void), that meant that the function had the type of void then?
    Does this mean i can omit type when deciding what type of function they should point at (and get a default of void)?
    Last edited by tzpb8; 07-26-2006 at 01:46 PM.

  3. #33
    1 == 1 tzpb8's Avatar
    Join Date
    Jul 2006
    Posts
    36
    Think i'm on to something?
    Code:
    #include <stdio.h>
    int sUP3r(int a);
    int g1uE(int a);
    
    int main(void){
    int a = 18;
    int (* array[3]) (int sUP3r) (int blue);
    int (* n) = &a;
    int (* o);
    int (* p);
    
    *array = *n;
    sUP3r(a);
    g1uE(a);
    printf("\n%d",array[0]);
        
    return 0;}
    
    int sUP3r(int a){
    int blue = 255;
    }
    
    int g1uE(int a){
    a = a + 5;
    printf("%d",a);
    }

  4. #34
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >int (* array[3]) (int sUP3r) (int blue);
    What on earth is that supposed to be?
    My best code is written with the delete key.

  5. #35
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by MDofRockyView
    As far as I know, if you omit the type, than it is implicitly marked as type void, so long as the compiler follows the standard. There is something called the ANSI/ISO C99 standard. It describes the C programming language and it is maintained by a volunteer comittee. The standard specifies the requirements of the language.
    Man you're stupid. No. If you omit the type, it defaults to an int. This is why when you leave out the header file for say string functions, you keep getting "pointer from integer" conversion errors and warnings.

    If you don't know the answer, don't try, just shut the hell up. You're a swirling vortex of misinformation. Please go away.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #36
    1 == 1 tzpb8's Avatar
    Join Date
    Jul 2006
    Posts
    36
    an pointer array of three pointer types pointing to function type int named sUP3r with the parameter blue int type

  7. #37
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    > int sUP3r(int a);
    > int g1uE(int a);

    I'm sure I and some other people would appreciate it if you stopped writing tokens and function names in 1337 and jibberish.

  8. #38
    1 == 1 tzpb8's Avatar
    Join Date
    Jul 2006
    Posts
    36
    jibberish makes more sence if mixed with logic

  9. #39
    ex-DECcie
    Join Date
    Dec 2005
    Posts
    125
    Quote Originally Posted by tzpb8
    an pointer array of three pointer types pointing to function type int named sUP3r with the parameter blue int type
    There's a program on Linux (and other Unix systems) called "cdecl" which can help with C declarations.

    Here's what I got with your line:

    cdecl> explain int (* array[3]) (int sUP3r) (int blue);
    parse error


    So, what you're doing doesn't even parse properly....
    Mr. Blonde: You ever listen to K-Billy's "Super Sounds of the Seventies" weekend? It's my personal favorite.

  10. #40
    1 == 1 tzpb8's Avatar
    Join Date
    Jul 2006
    Posts
    36
    yeah i know lol.. thats why i asked if i'm on to something
    'array' declared as function returning a function -is one of the warning i got

  11. #41
    ex-DECcie
    Join Date
    Dec 2005
    Posts
    125
    Quote Originally Posted by tzpb8
    jibberish makes more sence if mixed with logic
    And horsecrap put in a pretty bag with a bow on it is still horsecrap.

    You're certainly not making it easier for folks trying to help you.....
    Mr. Blonde: You ever listen to K-Billy's "Super Sounds of the Seventies" weekend? It's my personal favorite.

  12. #42
    1 == 1 tzpb8's Avatar
    Join Date
    Jul 2006
    Posts
    36
    If it's a problem i can stop writing numbers in function names, just thought it looked nicer.. like how you like to have whitespace

  13. #43
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >an pointer array of three pointer types pointing to function type int named sUP3r with the parameter blue int type
    Please, please take my advice about getting a strong foundation in the fundamentals before moving on to more advanced stuff. You're trying to move too quickly, and it's not helping. First, we have no interest in teaching you something you refuse to learn properly. Second, if you don't have a solid handle on the basics, everything built on those basics will be weak. In other words, you're on the path to becoming a horrible programmer.

    I don't want to see that happen.
    My best code is written with the delete key.

  14. #44
    1 == 1 tzpb8's Avatar
    Join Date
    Jul 2006
    Posts
    36
    I see, wanted to master pointers but i guess its to early

  15. #45
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I see, wanted to master pointers but guess its to early
    Programming is a skill. Like any other skill, it takes time to master. If you get in a hurry and try to cram more and more into your head when you aren't prepared for it, you make things harder on yourself. Be patient, enjoy the ride, and mastery will come of its own accord.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  2. char pointers and their addresses.
    By ens_leader in forum C Programming
    Replies: 5
    Last Post: 12-31-2007, 01:48 AM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  4. Im so lost at . .
    By hermit in forum C Programming
    Replies: 18
    Last Post: 05-15-2002, 01:26 AM
  5. Pointers and their Addresses
    By incognito in forum C++ Programming
    Replies: 6
    Last Post: 12-29-2001, 07:16 PM