passing an int array into function

This is a discussion on passing an int array into function within the C++ Programming forums, part of the General Programming Boards category; Code: int cbarray[20] = { "IDC_CHECK1", "IDC_CHECK2", "IDC_CHECK3", "IDC_CHECK4", "IDC_CHECK5", "IDC_CHECK6", "IDC_CHECK7", "IDC_CHECK8", "IDC_CHECK9", "IDC_CHECK10", "IDC_CHECK11", "IDC_CHECK12", "IDC_CHECK13", "IDC_CHECK14", "IDC_CHECK15", ...

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

    passing an int array into function

    Code:
    
    int  cbarray[20] = 
    { 
    "IDC_CHECK1", 
    "IDC_CHECK2", 
    "IDC_CHECK3",
    "IDC_CHECK4", 
    "IDC_CHECK5", 
    "IDC_CHECK6",
    "IDC_CHECK7", 
    "IDC_CHECK8", 
    "IDC_CHECK9",
    "IDC_CHECK10",
    "IDC_CHECK11", 
    "IDC_CHECK12", 
    "IDC_CHECK13", 
    "IDC_CHECK14",
    "IDC_CHECK15",
    "IDC_CHECK16", 
    "IDC_CHECK17", 
    "IDC_CHECK18", 
    "IDC_CHECK19",
    "IDC_CHECK20"
    ;}*/
            
    
    
    
    
    
    
    
    void checkall()			
    {int i=0;
    	for(i=0; i<21 < i++)
    	{
    		SendDlgItemMessage(hwnd,cbarray[i], BM_SETSTATE, (WPARAM)TRUE, 0);
    	}
    
    }
    on msdn
    http://msdn.microsoft.com/library/de...temmessage.asp
    says that the identifier of the control is of type "int"
    so i put the identifiers into an array of type int and try to pass into a "for" loop
    but doesnt work.......
    getting " error C2440: 'initializing' : cannot convert from 'char [12]' to 'unsigned int'
    This conversion requires a reinterpret_cast, a C-style cast or function-style cast"

    any idea??

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,764
    No idea

    But "IDC_CHECK1", isn't an int, its a string

    Given the type of the array, perhaps you meant
    IDC_CHECK1,
    IDC_CHECK2,

    However, the name of the array suggests strings, so perhaps it should be
    char *cbarray[20] =
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 12:45 PM
  2. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  3. Replies: 4
    Last Post: 11-23-2003, 07:15 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 06:05 PM

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