Thread: initializing char array inside a struct

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    You can't initialize a variable inside a struct.

  2. #2
    Registered User
    Join Date
    Jun 2006
    Posts
    28
    Quote Originally Posted by MacGyver View Post
    You can't initialize a variable inside a struct.
    agreed but how do i initialize it? i tried
    Code:
    char *index[INDEXSIZE];
    inside the struct body while trying to initialize outside with this:
    Code:
    st1.index[]={"debug","itterations","population",
    		"no fix vehicles","pm","pc"};
    but i get the following message
    Code:
    teststring.c:25: error: expected expression before ‘]’ token
    i tried several alternatives (changing the array size declaration, leaving it flexible etc) but i get the above message or something alternative with "{" . i know something is wrong with the expression i use but i can't figure out what...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Replies: 7
    Last Post: 06-16-2006, 09:23 PM
  3. What's wrong with my search program?
    By sherwi in forum C Programming
    Replies: 5
    Last Post: 04-28-2006, 09:57 AM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM