about arrays create within a struct~

This is a discussion on about arrays create within a struct~ within the C Programming forums, part of the General Programming Boards category; Struct String { char s[ ]; } when compiling the above code, error says a number need to be put ...

  1. #1
    Unregistered
    Guest

    Unhappy about arrays create within a struct~

    Struct String
    {
    char s[ ];
    }

    when compiling the above code, error says a number need to be put into []. But what can do if I want to leave it 'open'??

  2. #2
    Registered User stautze's Avatar
    Join Date
    Apr 2002
    Posts
    195
    char *s

  3. #3
    Unregistered
    Guest
    change to

    char *s;

    And remember to assign an allocated memory pointer to s

    ====>
    char s[] is equivalent to char *s but slightly different

    char s[] ==> s is not a LValue and can not be modified
    char *s ==> s can be manipulated, assignment, increment, decrement .....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create two arrays from command line and work on them
    By simpatico_qa in forum C Programming
    Replies: 30
    Last Post: 03-14-2009, 10:37 AM
  2. Function to read in two arrays
    By ssmokincamaro in forum C Programming
    Replies: 7
    Last Post: 11-12-2008, 06:59 AM
  3. dynamic memory and arrays
    By jomns in forum C++ Programming
    Replies: 4
    Last Post: 01-04-2004, 01:18 PM
  4. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM
  5. writing arrays to files
    By Zaarin in forum C++ Programming
    Replies: 1
    Last Post: 08-30-2001, 11:26 PM

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