Structures with variable length array known at compile time

Discussion in 'C Programming' started by aravind, Sep 14, 2008.

  1. aravind

    aravind Guest

    Hi, I need to develop a menu system for a project of mine. The menu
    will be displayed on a character LCD display driven by ARM7
    Microcontroller. For this purpose i wish to construct a structure in C
    which will contain a the following -
    struct menu
    {
    int n (no. of elements in menu);
    char menu_items[20][q]; (This will contains the strings to be
    displayed on the LCD, 20 characters and n lines
    funcptr fptr; (Pointer to the corresponding menu function)
    }
    the array "menu_items" will always have 20 character strings but the
    no. of them 'q' will differ from each menu screen. the no. of strings
    will be defined in "int n". I will be using this struct to implement
    const structs which i will be defining with all the menu screen
    information.
    From googling around i found variable length arrays cannot be
    implemented with in structures. I also found that the structure size
    should be known at compile time(i dont want to use malloc). My menu
    items will be known at compile time. how do i implement this?
    Thanks.
    aravind, Sep 14, 2008
    #1
    1. Advertising

  2. aravind <> writes:

    > Hi, I need to develop a menu system for a project of mine.

    <snip>
    > struct menu
    > {
    > int n (no. of elements in menu);
    > char menu_items[20][q]; (This will contains the strings to be
    > displayed on the LCD, 20 characters and n lines
    > funcptr fptr; (Pointer to the corresponding menu function)
    > }
    > the array "menu_items" will always have 20 character strings but the
    > no. of them 'q' will differ from each menu screen. the no. of strings
    > will be defined in "int n".


    This looks like homework (usually called coursework here in the UK) so
    I am reluctant to post code. I will point out a couple of things...

    You have the array the wrong what round -- what you wrote is an array
    of 20 arrays of q characters each.

    If the strings are to be 20 characters, it is better to use 21
    character arrays and always have a null at the end. I.e. always keep
    a proper string. If memory if very tight you can avoid this, but the
    coding gets much more fiddly.

    > I will be using this struct to implement
    > const structs which i will be defining with all the menu screen
    > information.
    > From googling around i found variable length arrays cannot be
    > implemented with in structures. I also found that the structure size
    > should be known at compile time(i dont want to use malloc). My menu
    > items will be known at compile time. how do i implement this?


    One way is to have a pointer to an array. These are a little odd, but
    you have function pointers so array pointer are only a small step
    away! Define the string array separately and then point to in when
    you initialise the menu struct.

    --
    Ben.
    Ben Bacarisse, Sep 14, 2008
    #2
    1. Advertising

  3. aravind

    CBFalconer Guest

    aravind wrote:
    >
    > Hi, I need to develop a menu system for a project of mine. The
    > menu will be displayed on a character LCD display driven by ARM7
    > Microcontroller. For this purpose i wish to construct a structure
    > in C which will contain a the following -


    Besides the fact that this appears to be homework, it is
    off-topic. c.l.c deals with the C language, as defined in the
    various C standards. comp.arch.embedded might be a better place,
    if it wasn't homework.

    --
    [mail]: Chuck F (cbfalconer at maineline dot net)
    [page]: <http://cbfalconer.home.att.net>
    Try the download section.
    CBFalconer, Sep 14, 2008
    #3
  4. aravind

    Richard Guest

    CBFalconer <> writes:

    > aravind wrote:
    >>
    >> Hi, I need to develop a menu system for a project of mine. The
    >> menu will be displayed on a character LCD display driven by ARM7
    >> Microcontroller. For this purpose i wish to construct a structure
    >> in C which will contain a the following -

    >
    > Besides the fact that this appears to be homework, it is
    > off-topic. c.l.c deals with the C language, as defined in the
    > various C standards. comp.arch.embedded might be a better place,
    > if it wasn't homework.


    He is asking advice on how best to design a structure. The rest of the
    information is merely "in addition" and might well lead responsible
    senior programmers to guide him more thoroughly.

    If you wish to be disruptive and unhelpful please at least wait for
    people who do indeed post off topic.

    His question was polite and on topic for the C programming language.

    Please take the effort to read the posts you are so quick to denigrate.
    Richard, Sep 14, 2008
    #4
  5. aravind

    Bartc Guest

    "aravind" <> wrote in message
    news:...
    > Hi, I need to develop a menu system for a project of mine. The menu
    > will be displayed on a character LCD display driven by ARM7
    > Microcontroller. For this purpose i wish to construct a structure in C
    > which will contain a the following -
    > struct menu
    > {
    > int n (no. of elements in menu);
    > char menu_items[20][q]; (This will contains the strings to be
    > displayed on the LCD, 20 characters and n lines
    > funcptr fptr; (Pointer to the corresponding menu function)
    > }
    > the array "menu_items" will always have 20 character strings but the
    > no. of them 'q' will differ from each menu screen. the no. of strings
    > will be defined in "int n". I will be using this struct to implement
    > const structs which i will be defining with all the menu screen
    > information.
    > From googling around i found variable length arrays cannot be
    > implemented with in structures. I also found that the structure size
    > should be known at compile time(i dont want to use malloc). My menu
    > items will be known at compile time. how do i implement this?
    > Thanks.


    Just use this:

    #define maxrows 16 /* Or whatever */
    #define columns 20 /* Or 21 if strings used */

    struct menu {
    int n; /* Menu rows in use */
    char menu_items[maxrows][columns];
    funcptr fptr;
    };

    --
    Bartc
    Bartc, Sep 14, 2008
    #5
  6. aravind

    aravind Guest

    On Sep 14, 9:45 pm, Richard Heathfield <> wrote:
    > aravind said:
    >
    > > Hi, I need to develop a menu system for a project of mine. The menu
    > > will be displayed on a character LCD display driven by ARM7
    > > Microcontroller. For this purpose i wish to construct a structure in C
    > > which will contain a the following -
    > > struct menu
    > > {
    > >      int n (no. of elements in menu);
    > >      char menu_items[20][q]; (This will contains the strings to be
    > > displayed on the LCD, 20 characters and n lines

    >
    > Then you'll want that the other way around. Conceptually:
    >
    >        char menu_items[n][20];
    >
    > Unfortunately, this isn't legal C. But fear not - there'll be a way...
    >
    > >      funcptr fptr; (Pointer to the corresponding menu function)
    > > }
    > > the array "menu_items" will always have 20 character strings but the
    > > no. of them 'q' will differ from each menu screen. the no. of strings
    > > will be defined in "int n". I will be using this struct to implement
    > > const structs which i will be defining with all the menu screen
    > > information.
    > > From googling around i found variable length arrays cannot be
    > > implemented with in structures. I also found that the structure size
    > > should be known at compile time(i dont want to use malloc).

    >
    > ...but by outlawing malloc, you make it very difficult!
    >
    > > My menu
    > > items will be known at compile time. how do i implement this?

    >
    > Frankly, the right answer is "malloc". Failing that, the best I can think
    > of is to have the string data in some humungous great static-qualified
    > array, and replace char menu_items[n][20] with int menu_items[N] for some
    > sufficiently large N, where menu_items (i ranging from 0 to
    > yourstruct.n - 1, of course) gives the index into the humungous great
    > static-qualified array for the ith string in the display.
    >
    > This will waste some space (the malloc solution would be more
    > space-efficient), but not as much as you'd waste otherwise, I think.
    >
    > --
    > Richard Heathfield <http://www.cpax.org.uk>
    > Email: -http://www. +rjh@
    > Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    > "Usenet is a strange place" - dmr 29 July 1999

    The reason i dont want to use malloc is that the all the menu items/
    elements are defined at compile time and will be stored like a lookup
    table in the flash code memory on the microcontroller. So there's no
    dynamic allocation. If i were to use malloc the space would allocated
    from onchip RAM of which i have only 64KB. the flash has a more
    generous 256KB.

    I'm new to writing programs at this level of complexity with 70-100
    different menu screens and associated functions, so i'm not sure
    what's best approach to such a problem. How can we design software for
    menu based applications. I'd be glad to hear your ideas. Thanks

    >This looks like homework (usually called coursework here in the UK) so
    >I am reluctant to post code.

    No this is not homework/coursework, I'm working on a 5.1 audio power
    amplifier system(DIY). The microcontroller will control the the
    amplifier and provide remote controlled menu based interface for the
    user. You can have look at what i'm working on here->
    http://picasaweb.google.com/aramosfet

    Thanks for you replies...
    aravind, Sep 14, 2008
    #6
  7. aravind

    aravind Guest

    On Sep 14, 10:38 pm, "Bartc" <> wrote:
    > "aravind" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > Hi, I need to develop a menu system for a project of mine. The menu
    > > will be displayed on a character LCD display driven by ARM7
    > > Microcontroller. For this purpose i wish to construct a structure in C
    > > which will contain a the following -
    > > struct menu
    > > {
    > >     int n (no. of elements in menu);
    > >     char menu_items[20][q]; (This will contains the strings to be
    > > displayed on the LCD, 20 characters and n lines
    > >     funcptr fptr; (Pointer to the corresponding menu function)
    > > }
    > > the array "menu_items" will always have 20 character strings but the
    > > no. of them 'q' will differ from each menu screen. the no. of strings
    > > will be defined in "int n". I will be using this struct to implement
    > > const structs which i will be defining with all the menu screen
    > > information.
    > > From googling around i found variable length arrays cannot be
    > > implemented with in structures. I also found that the structure size
    > > should be known at compile time(i dont want to use malloc). My menu
    > > items will be known at compile time. how do i implement this?
    > > Thanks.

    >
    > Just use this:
    >
    > #define maxrows 16    /* Or whatever */
    > #define columns 20    /* Or 21 if strings used */
    >
    > struct menu {
    >  int n;     /* Menu rows in use */
    >  char menu_items[maxrows][columns];
    >  funcptr fptr;
    >
    > };
    >
    > --
    > Bartc


    if i were to declare an array of such const structs, each having a
    different value of maxrows would the compiler allocate space for 16
    rows as in typedef or would it optimize and allocate space only for
    the rows which have been initialized.

    Each menu can have different no. of menu items so i want to use only
    as much memory as required for this..
    --
    aramosfet
    aravind, Sep 14, 2008
    #7
  8. aravind

    Bartc Guest

    aravind wrote:
    > On Sep 14, 10:38 pm, "Bartc" <> wrote:


    >> #define maxrows 16 /* Or whatever */
    >> #define columns 20 /* Or 21 if strings used */
    >>
    >> struct menu {
    >> int n; /* Menu rows in use */
    >> char menu_items[maxrows][columns];
    >> funcptr fptr;


    > if i were to declare an array of such const structs, each having a
    > different value of maxrows would the compiler allocate space for 16
    > rows as in typedef or would it optimize and allocate space only for
    > the rows which have been initialized.
    >
    > Each menu can have different no. of menu items so i want to use only
    > as much memory as required for this..


    If you are short of memory and don't want to use malloc() then you need a
    different approach.

    Also, storing 20 characters per element would also be wasteful if elements
    are shorter than that.

    But perhaps try this:

    char *menustrings[] = {
    "menu1 row1", /* 0 Substitute actual text */
    "menu1 row2", /* 1 */
    "menu1 row3", /* 2 */
    "menu2 row1", /* 3 */
    "menu3 row1", /* 4 */
    "menu3 row2"}; /* 5 */

    struct menu {
    int startindex; /* Start index of 1st elem in menustrings */
    int n; /* Number of elements from menustrings */
    funcptr fptr;
    };

    struct menu menulist[] = {
    {0,3, 0}, /* Replace final 0 with funcptr value */
    {3,1, 0},
    {4,2, 0}};


    int main(void){
    puts(menustrings[menulist[2].startindex]); /* Show first elem of 3rd
    menu */
    }

    This will minimise string storage. You can also use short int inside the
    struct.

    --
    bartc
    Bartc, Sep 14, 2008
    #8
  9. aravind <> writes:

    > On Sep 14, 9:45 pm, Richard Heathfield <> wrote:
    >> aravind said:
    >>
    >> > Hi, I need to develop a menu system for a project of mine.

    <snip>
    >> > struct menu
    >> > {
    >> >      int n (no. of elements in menu);
    >> >      char menu_items[20][q]; (This will contains the strings to be
    >> > displayed on the LCD, 20 characters and n lines
    >> >      funcptr fptr; (Pointer to the corresponding menu function)
    >> > }

    <snip>
    >> > My menu
    >> > items will be known at compile time. how do i implement this?

    >>
    >> Frankly, the right answer is "malloc". Failing that, the best I can think
    >> of is to have the string data in some humungous great static-qualified
    >> array, and replace char menu_items[n][20] with int menu_items[N] for some
    >> sufficiently large N, where menu_items (i ranging from 0 to
    >> yourstruct.n - 1, of course) gives the index into the humungous great
    >> static-qualified array for the ith string in the display.

    <snip>
    > The reason i dont want to use malloc is that the all the menu items/
    > elements are defined at compile time and will be stored like a lookup
    > table in the flash code memory on the microcontroller. So there's no
    > dynamic allocation.

    <snip>
    > I'm new to writing programs at this level of complexity with 70-100
    > different menu screens and associated functions, so i'm not sure
    > what's best approach to such a problem. How can we design software for
    > menu based applications. I'd be glad to hear your ideas. Thanks
    >
    >>This looks like homework (usually called coursework here in the UK) so
    >>I am reluctant to post code.

    > No this is not homework/coursework, I'm working on a 5.1 audio power
    > amplifier system(DIY). The microcontroller will control the the
    > amplifier and provide remote controlled menu based interface for the
    > user.


    OK, I can make a suggestion with a clear conscience! I would do it
    like this:

    typedef void (*funcptr)(void);

    struct menu {
    int n;
    char (*strings)[21];
    funcptr fptr;
    };

    char menu1_strings[][21] = {
    "abc",
    "def",
    "ghi"
    };

    void menu1_func(void)
    {
    /* ... as required */
    }

    struct menu menu1 = {
    sizeof menu1_strings / sizeof menu1_strings[0],
    menu1_strings,
    menu1_func
    };


    The use of a pointer to an and array is odd but a reasonable strategy
    here. Note that there is no need to waste the space a having 20
    character strings -- this could be re-done like this:

    struct menu {
    int n;
    const char **strings;
    funcptr fptr;
    };

    const char *menu1_strings[] = {
    "abc",
    "def",
    "ghi"
    };

    struct menu menu1 = {
    sizeof menu1_strings / sizeof menu1_strings[0],
    menu1_strings,
    menu1_func
    };

    --
    Ben.
    Ben Bacarisse, Sep 14, 2008
    #9
  10. aravind

    Tim Rentsch Guest

    aravind <> writes:

    > Hi, I need to develop a menu system for a project of mine. The menu
    > will be displayed on a character LCD display driven by ARM7
    > Microcontroller. For this purpose i wish to construct a structure in C
    > which will contain a the following -
    > struct menu
    > {
    > int n (no. of elements in menu);
    > char menu_items[20][q]; (This will contains the strings to be
    > displayed on the LCD, 20 characters and n lines
    > funcptr fptr; (Pointer to the corresponding menu function)
    > }
    > the array "menu_items" will always have 20 character strings but the
    > no. of them 'q' will differ from each menu screen. the no. of strings
    > will be defined in "int n". I will be using this struct to implement
    > const structs which i will be defining with all the menu screen
    > information.
    > From googling around i found variable length arrays cannot be
    > implemented with in structures. I also found that the structure size
    > should be known at compile time(i dont want to use malloc). My menu
    > items will be known at compile time. how do i implement this?
    > Thanks.


    This case is one where a pointer to array might be a good choice:

    struct menu {
    char (*items)[20]; /* pointer to array of item strings */
    int n; /* number of items */
    funcptr f;
    };

    char menu_1_strings[][20] = {
    "first item",
    "second item",
    "third item",
    };

    struct menu menu_1 = {
    menu_1_strings,
    sizeof menu_1_strings / sizeof *menu_1_strings,
    menu_1_f
    };


    /* now use menu_1.items[k] to get the k'th item string in menu_1 */

    For convenience you might want to put in a typedef for an item string
    type, and maybe a #define so the various 'struct menu' definitions
    are a little more succinct. I left everything explicit so it would
    be more clear how everything fits together.
    Tim Rentsch, Sep 15, 2008
    #10
  11. aravind

    Old Wolf Guest

    On Sep 15, 2:33 am, aravind <> wrote:
    > From googling around i found variable length arrays cannot be
    > implemented with in structures. I also found that the structure size
    > should be known at compile time(i dont want to use malloc). My menu
    > items will be known at compile time. how do i implement this?


    I would make your menu structure contain a
    pointer to a list of menu items. For example:

    const char *mainmenu_items[] =
    { "item 1", "item number 2", "3", "supercalifragilistic" };


    const struct menu mainmenu =
    { mainmenu_items, dimof(mainmenu_items), q };
    Old Wolf, Sep 15, 2008
    #11
  12. On 14 Sep, 17:28, CBFalconer <> wrote:
    > aravind wrote:
    >
    > > Hi, I need to develop a menu system for a project of mine. The
    > > menu will be displayed on a character LCD display driven by ARM7
    > > Microcontroller. For this purpose i wish to construct a structure
    > > in C which will contain a the following -

    >
    > Besides the fact that this appears to be homework, it is
    > off-topic.  c.l.c deals with the C language, as defined in the
    > various C standards.  comp.arch.embedded might be a better place,
    > if it wasn't homework.


    don't talk rubbish. The question is on-topic.

    --
    Nick Keighley
    Nick Keighley, Sep 15, 2008
    #12
  13. On 14 Sep, 17:45, Richard Heathfield <> wrote:

    > > Hi, I need to develop a menu system for a project of mine. The menu
    > > will be displayed on a character LCD display driven by ARM7
    > > Microcontroller. For this purpose i wish to construct a structure in C
    > > which will contain a the following -
    > > struct menu
    > > {
    > >      int n (no. of elements in menu);
    > >      char menu_items[20][q]; (This will contains the strings to be
    > > displayed on the LCD, 20 characters and n lines

    >
    > Then you'll want that the other way around. Conceptually:
    >
    >        char menu_items[n][20];
    >
    > Unfortunately, this isn't legal C. But fear not - there'll be a way...
    >
    > >      funcptr fptr; (Pointer to the corresponding menu function)
    > > }


    > > the array "menu_items" will always have 20 character strings but the
    > > no. of them 'q' will differ from each menu screen. the no. of strings
    > > will be defined in "int n". I will be using this struct to implement
    > > const structs which i will be defining with all the menu screen
    > > information.
    > > From googling around i found variable length arrays cannot be
    > > implemented with in structures. I also found that the structure size
    > > should be known at compile time(i dont want to use malloc).

    >
    > ...but by outlawing malloc, you make it very difficult!


    it doesn't seem *that* difficult!

    struct menu
    {
    int n (no. of elements in menu);
    char menu_items[20][q];
    char menu_items[n][20
    };

    const char* menu_string[] =
    {"menu A", "menu B", "menu C"};

    struct menu file_menu =
    {2, {&menu_string[0], &menu_string[1]}, file_fp};

    and since I didn't test this there are bound to be errors...

    menu_string could also be a 2D array.



    > > My menu
    > > items will be known at compile time. how do i implement this?

    >
    > Frankly, the right answer is "malloc". Failing that, the best I can think
    > of is to have the string data in some humungous great static-qualified
    > array, and replace char menu_items[n][20] with int menu_items[N] for some
    > sufficiently large N, where menu_items (i ranging from 0 to
    > yourstruct.n - 1, of course) gives the index into the humungous great
    > static-qualified array for the ith string in the display.


    and why is this bad?


    > This will waste some space (the malloc solution would be more
    > space-efficient), but not as much as you'd waste otherwise, I think.


    I'd have thought you could get the memory efficeincy
    with a "jagged" array.


    --
    Nick Keighley

    The fscanf equivalent of fgets is so simple
    that it can be used inline whenever needed:-
    char s[NN + 1] = "", c;
    int rc = fscanf(fp, "%NN[^\n]%1[\n]", s, &c);
    if (rc == 1) fscanf("%*[^\n]%*c);
    if (rc == 0) getc(fp);
    (Dan Pop)
    Nick Keighley, Sep 15, 2008
    #13
  14. On 15 Sep, 10:17, Richard Heathfield <> wrote:
    > Nick Keighley said:
    > > On 14 Sep, 17:45, Richard Heathfield <> wrote:


    > >> ...but by outlawing malloc, you make it very difficult!

    >
    > > it doesn't seem *that* difficult!


    obviously it *should* have looked difficult...


    > > struct menu
    > > {
    > >      int n (no. of elements in menu);

    >
    > Perhaps you would care to put a value on n. The OP can't. He said that the
    > number varies, but is known at compilation time. That is, he has /several/
    > menus, with varying numbers of entries, but he appears to want a single
    > struct type that can cope with all of them, ...
    >
    > >       char menu_items[20][q];
    > >         char menu_items[n][20

    >
    > ... so this won't do.


    <snip embarrassing code>

    ok, how about linked lists using a pool of
    preallocated nodes

    struct menu_item_node
    {
    struct menu_item_node *next;
    char menu_item[21];
    };


    > >> Frankly, the right answer is "malloc". Failing that, the best I can
    > >> think of is to have the string data in some humungous great
    > >> static-qualified array, and replace char menu_items[n][20] with int
    > >> menu_items[N] for some sufficiently large N, where menu_items (i
    > >> ranging from 0 to yourstruct.n - 1, of course) gives the index into the
    > >> humungous great static-qualified array for the ith string in the
    > >> display.

    >
    > > and why is this bad?

    >
    > It's not ghastly bad - it's just not as neat as dynamically allocating
    > exactly enough memory, and it will inevitably waste some space.


    <snip>

    --
    Nick Keighley

    My god it's full of stars!
    Dave Bowman, on seeing HAL's source code
    Nick Keighley, Sep 15, 2008
    #14
  15. aravind

    Bartc Guest

    "Bartc" <> wrote in message
    news:wOczk.57676$...
    > aravind wrote:


    >> Each menu can have different no. of menu items so i want to use only
    >> as much memory as required for this..


    > char *menustrings[] = {
    > "menu1 row1", /* 0 Substitute actual text */
    > "menu1 row2", /* 1 */
    > "menu1 row3", /* 2 */
    > "menu2 row1", /* 3 */
    > "menu3 row1", /* 4 */
    > "menu3 row2"}; /* 5 */
    >
    > struct menu {
    > int startindex; /* Start index of 1st elem in menustrings */
    > int n; /* Number of elements from menustrings */
    > funcptr fptr;
    > };


    I think I was confused with another thread where someone wasn't allowed to
    use pointers, but, yes, the .startindex field is best replaced by some
    char** pointer to a dedicated char* array, one per menu, as suggested
    elsewhere.

    (Unless your compiler can only cope with a single char* array, then this
    would be perfect.)

    --
    Bartc
    Bartc, Sep 15, 2008
    #15
  16. Nick Keighley <> writes:

    > On 15 Sep, 10:17, Richard Heathfield <> wrote:
    >> Nick Keighley said:
    >> > On 14 Sep, 17:45, Richard Heathfield <> wrote:

    >
    >> >> ...but by outlawing malloc, you make it very difficult!

    >>
    >> > it doesn't seem *that* difficult!

    >
    > obviously it *should* have looked difficult...


    Can someone explain what the problem is? The OP started off thinking
    that char strings[n][20]; would do but we know it won't. One can
    waste a little and use char (*strings)[20]; or one can just have char
    **strings; and initialise that with a bunch of literals via a named
    array (as posted by at least three people, I think).

    It seems that I am missing why this is considered hard or a problem if
    malloc is not allowed.

    --
    Ben.
    Ben Bacarisse, Sep 15, 2008
    #16
  17. aravind

    aramosfet Guest

    Thank you all for your replies and code snippets, i will try your
    ideas when i start with coding today...
    --
    aramosfet
    aramosfet, Sep 15, 2008
    #17
  18. aravind

    CBFalconer Guest

    Nick Keighley wrote:
    > CBFalconer <> wrote:
    >> aravind wrote:
    >>
    >>> Hi, I need to develop a menu system for a project of mine. The
    >>> menu will be displayed on a character LCD display driven by ARM7
    >>> Microcontroller. For this purpose i wish to construct a structure
    >>> in C which will contain a the following -

    >>
    >> Besides the fact that this appears to be homework, it is
    >> off-topic. c.l.c deals with the C language, as defined in the
    >> various C standards. comp.arch.embedded might be a better place,
    >> if it wasn't homework.

    >
    > don't talk rubbish. The question is on-topic.


    Oh? You think ARM Micros and char LCD displays are on-topic?
    Possibly they are never referenced again, but reading the post to
    this point doesn't make that evident.

    --
    [mail]: Chuck F (cbfalconer at maineline dot net)
    [page]: <http://cbfalconer.home.att.net>
    Try the download section.
    CBFalconer, Sep 15, 2008
    #18
  19. aravind

    Guest

    On Sep 15, 11:07 pm, CBFalconer <> wrote:
    > Nick Keighley wrote:
    > > CBFalconer <> wrote:
    > >> aravind wrote:

    >
    > >>> Hi, I need to develop a menu system for a project of mine. The
    > >>> menu will be displayed on a character LCD display driven by ARM7
    > >>> Microcontroller. For this purpose i wish to construct a structure
    > >>> in C which will contain a the following -

    >
    > >> Besides the fact that this appears to be homework, it is
    > >> off-topic. c.l.c deals with the C language, as defined in the
    > >> various C standards. comp.arch.embedded might be a better place,
    > >> if it wasn't homework.

    >
    > > don't talk rubbish. The question is on-topic.

    >
    > Oh? You think ARM Micros and char LCD displays are on-topic?
    > Possibly they are never referenced again, but reading the post to
    > this point doesn't make that evident.


    His question was on-topic. The background information was not.

    Similar to:

    I have many cats and I want an array to keep all their names.
    I have this:

    char **cat_names;

    But I'm confused about using malloc with this... Can anyone help?

    Cats are not on-topic. The question is.
    , Sep 15, 2008
    #19
  20. CBFalconer <> writes:
    > Nick Keighley wrote:
    >> CBFalconer <> wrote:
    >>> aravind wrote:
    >>>
    >>>> Hi, I need to develop a menu system for a project of mine. The
    >>>> menu will be displayed on a character LCD display driven by ARM7
    >>>> Microcontroller. For this purpose i wish to construct a structure
    >>>> in C which will contain a the following -
    >>>
    >>> Besides the fact that this appears to be homework, it is
    >>> off-topic. c.l.c deals with the C language, as defined in the
    >>> various C standards. comp.arch.embedded might be a better place,
    >>> if it wasn't homework.

    >>
    >> don't talk rubbish. The question is on-topic.

    >
    > Oh? You think ARM Micros and char LCD displays are on-topic?
    > Possibly they are never referenced again, but reading the post to
    > this point doesn't make that evident.


    No, it doesn't. Reading past that point does. If you don't have time
    to read more than the first paragraph of a post, I'm surprised you
    have time to post a followup claiming that it's off-topic.

    aravind's was topical. He provided some background regarding the
    motivation for what he's trying to do (something that too few posters
    do). The fact that you didn't realize it was topical is your fault,
    not his.

    I don't recall seeing an off-topic post for which you, but nobody
    else, pointed out that it was off-topic. I think you can safely take
    a break. We've got it covered.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Sep 15, 2008
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JKop

    Known at compile-time

    JKop, Jul 20, 2004, in forum: C++
    Replies:
    13
    Views:
    543
    Richard Herring
    Jul 20, 2004
  2. Alfonso Morra
    Replies:
    11
    Views:
    701
    Emmanuel Delahaye
    Sep 24, 2005
  3. Carter
    Replies:
    2
    Views:
    488
    Carter
    Mar 4, 2009
  4. TFS_PhDgirl
    Replies:
    0
    Views:
    250
    TFS_PhDgirl
    Mar 3, 2012
  5. Dejas
    Replies:
    5
    Views:
    204
    Bart Van der Donck
    Oct 14, 2007
Loading...

Share This Page