Results 1 to 4 of 4

Thread: why does this give me too many initialisers error?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    why does this give me too many initialisers error?

    char names[] = { "Mary", "Jordan" };

    i want to also store a string value for each name too, how can i do this guys?

    like.. Mary - female
    Jordan female etc

    so i want to store male or female for each person in the array

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: why does this give me too many initialisers error?

    because names is a char array in your program and while initialising, you are passing 2-d array items.

    if you make it 2-d array, then it will not give error.

    example: char *names[] (or you can use char names[][25] - in this you need to specify the second index)

    so Mary will be names[0][3], Jordan will be names[1][5].

    hope you get it now.
    Show Appreciation. Rate Posts.

  3. #3
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: why does this give me too many initialisers error?

    and how are you determining about the gender? will the user enter it?
    Show Appreciation. Rate Posts.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: why does this give me too many initialisers error?

    well im passing information to the dll from my client mIRC, e.g..

    //echo -a $dll(Test32.dll, TestFunction,0) echos

    Gupta

    heres the code..

    Code:
    extern "C" int WINAPI TestFunction(HWND, HWND, char *data, char *parms, BOOL, BOOL) {
    
    	char *names[] = { "Harsh", "Gupta", "pouncer" };
    
    	_fstrcpy( data , names[1] );
    
    	return 3;
    }
    but now im going to pass a full parameter to the dll like this

    /dll Test32.dll TestFunction Harsh-Male

    and i want it to store Harsh in 1 part of the array, and male in another and then somehow be able to get the gender of the person by their name

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width