Thread: creating an array of strings

  1. #1
    Registered User
    Join Date
    Mar 2004

    creating an array of strings

    juz 1 quick qns,
    how do u create an array of strings??

    char *hostarray= "Cmc-01 Cmc-02 Cmc-03 Cmc-04"; 
    //and test it by doing this
    MessageBox(hwnd,  hostarray[2] , "arrarytest", MB_OK);
    i am hoping this gives me hostarray[0] = "Cmc-01" , hostarray[1]= "Cmc-02" but it doesnt work

    kept getting the error

    "c:\program files\microsoft visual studio\projects\aaclient\array.h(56) : error C2664: 'MessageBoxA' : cannot convert parameter 2 from 'char' to 'const char *'
    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    Error executing cl.exe."

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Do this
    char *hostarray[] = {
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a menu that reads input via an array?
    By Nalif in forum C Programming
    Replies: 6
    Last Post: 09-29-2006, 09:21 PM
  2. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 09:51 AM
  3. Passing an Array of Strings from VB to a C DLL
    By mr_nice! in forum Windows Programming
    Replies: 9
    Last Post: 03-08-2005, 06:16 AM
  4. remove strings from array
    By ipe in forum C Programming
    Replies: 2
    Last Post: 01-12-2003, 04:53 AM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM