Thread: struct containing arrays.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Banned
    Join Date
    Apr 2015
    Posts
    596

    struct containing arrays.

    Firstly sorry and apologize for this silly question

    lets say I have this example(it's spontaneously) :
    Code:
    #include<stdio.h>
    #include<string.h>
    struct student {
            char name[15];}jay;
    int main()
    {
          jay.name="David";
          return 0;
    }
    I know there're errors in this code, and that's why I came for
    Well, to put the value "david" into the struct's name , I must access it and I accessed the struct by using operator "."(see in line 5), and now why I must write
    Code:
    jay.name
    , and not a
    Code:
    jay.name[15]
    , I'm saying that because the variable here not name alone it's name[15], so I must define that while trying to accessing... , and that's all..thanks.
    Last edited by RyanC; 08-13-2015 at 08:31 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need a litle help with Struct arrays
    By Crisapx in forum C Programming
    Replies: 2
    Last Post: 05-02-2015, 02:07 PM
  2. Struct Arrays
    By Jdo300 in forum C Programming
    Replies: 17
    Last Post: 03-09-2012, 03:16 PM
  3. arrays and struct !!
    By abood1190 in forum C Programming
    Replies: 9
    Last Post: 10-19-2011, 10:26 AM
  4. struct arrays
    By silentkarma in forum C++ Programming
    Replies: 9
    Last Post: 07-23-2008, 03:24 AM
  5. Problem with struct arrays...
    By Bizmark in forum C Programming
    Replies: 5
    Last Post: 03-27-2008, 07:46 PM