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.
Sep 14 '08
27 3300
On Mon, 15 Sep 2008 13:49:07 +0000, Richard Heathfield
<rj*@see.sig.in validwrote:
>Ben Bacarisse said:
>Nick Keighley <ni************ ******@hotmail. comwrites:
>>On 15 Sep, 10:17, Richard Heathfield <r...@see.sig.i nvalidwrote: Nick Keighley said: On 14 Sep, 17:45, Richard Heathfield <r...@see.sig.i nvalidwrote:
...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.
Probably my fault. I only meant that, with malloc, it would have been easy to provide a very efficient solution. I think that, without it, the solution is clunkier, harder to code, and less efficient. Given the probable origin of the question as homework, I am reluctant to provide the source that might conceivably explain what I mean far better than I can explain it in English.
The OP has already explained that it is not homework, and has
(briefly) explained the context and why he doesn't want to use
malloc. Since you seem to have missed it, here is the relevant
passage:
"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."
Richard Harter, cr*@tiac.net http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
Thank you all for your replies and code snippets, i will try your
ideas when i start with coding today...
--
aramosfet
Nick Keighley wrote:
CBFalconer <cbfalco...@yah oo.comwrote:
>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 Microcontroll er. 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.embed ded 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.
On Sep 15, 11:07 pm, CBFalconer <cbfalco...@yah oo.comwrote:
Nick Keighley wrote:
CBFalconer <cbfalco...@yah oo.comwrote:
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 Microcontrolle r. 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.embed ded 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.
CBFalconer <cb********@yah oo.comwrites:
Nick Keighley wrote:
>CBFalconer <cbfalco...@yah oo.comwrote:
>>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 Microcontrol ler. 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.embed ded 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_Keit h) ks***@mib.org <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"
In article <ln************ @nuthaus.mib.or g>,
Keith Thompson <ks***@mib.orgs ensibly chided our good friend CBF thusly:
....
>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.
Well done, sir! I see you and Richard (*) are finally on the same side
of an issue. That puts you on the right side for a change.
(*) He whom you often refer to as "he who has no last name" (or some
such piffle)
CBFalconer said:
Nick Keighley wrote:
>CBFalconer <cbfalco...@yah oo.comwrote:
>>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 Microcontrol ler. 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.embed ded 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?
No, but they are merely incidental - the question is on-topic.
If you must play topic-cop, please play good cop, not dumb cop.
Possibly they are never referenced again, but reading the post to
this point doesn't make that evident.
Try reading the *whole* article! It's only 21 lines, for Cthulhu's sake!
--
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
On Sep 16, 1:49*am, Richard Heathfield <r...@see.sig.i nvalidwrote:
Probably my fault. I only meant that, with malloc, it would have been easy
to provide a very efficient solution. I think that, without it, the
solution is clunkier, harder to code, and less efficient.
I think it's is clunkier, harder to code, and
less efficient with malloc!
(Assuming that all of the table entries are
known at compile time, as the OP said). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jim Hudon |
last post by:
i need to create an array of a size determined by a non-const variable:
int char sampleArray;
why does the following not work, and what can i do:
const int constArraySize = arraySize;
int char sampleArray[ constArraySize;
for both of the above, i get the same error message when i compile:
|
by: John Dann |
last post by:
I'm trying to read some binary data from a file created by another
program. I know the binary file format but can't change or control the
format. The binary data is organised such that it should populate a
series of structures of specified variable composition.
I have the structures created OK, but actually reading the files is
giving me an error. Can I ask a simple question to start with:
I'm trying to read the file using the...
|
by: Galen Somerville |
last post by:
And yet another VB6 to VB2005 problem. All helpful suggestions appreciated.
As you can see in the code below, my structures use fixed length strings and
known array sizes. Consequently I can save to files as a large byte array.
This is a series of Lectures where there is a capacity for 8 instructors
with up to 8 lectures each. So a parameters file made from glctInstTable is
2,232 bytes.
The 64 lectures, for the above, each consist of...
|
by: Martin Joergensen |
last post by:
Hi,
I wanted to try something which I think is a very good
exercise... I read in data from the keyboard and store them in a
structure. There's a pointer called "data_pointer" which I use to
keep track on the structures... But it's a bit confusing - my
program won't compile and I don't know what to do about the
warnings/error messages.
c:\documents and settings\dell\Desktop\test\main.c(5) : warning
|
by: farseer |
last post by:
i am getting "error C2057: expected constant expression" with the
following code:
ifstream f( argv );
f.seekg( 0, ios::end );
const long fSize = f.tellg();
f.close();
char content;
| |
by: gcary |
last post by:
I am having trouble figuring out how to declare a pointer to an array
of structures and initializing the pointer with a value. I've looked
at older posts in this group, and tried a solution that looked
sensible, but it didn't work right. Here is a simple example of what
I'm trying to accomplish:
// I have a hardware peripheral that I'm trying to access
// that has two ports. Each port has 10 sequential
// registers. Create a...
|
by: Pedro Pinto |
last post by:
Hi there once more........
Instead of showing all the code my problem is simple.
I've tried to create this function:
char temp(char *string){
alterString(string);
return string;
|
by: svata |
last post by:
Hello,
I wonder how to resize such array of structures using realloc()?
#include <stdio.h>
#include <stdlib.h>
#define FIRST 7
typedef struct {
char *name;
|
by: jaime |
last post by:
Hi all.
The source code download bundle for "Beginning C: From Novice to
Professional, Fourth Edition" (ISBN: 1590597354) (Horton/Apress)
contains a C source file (program9_09.c) which contains several instances
of the following type of idiom:
/* Program 9.9 REVERSI An Othello type game */
const int SIZE = 6;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |