472,799 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,799 software developers and data experts.

Creating array of (some_arr[DynamicSize]) structure. (struct xxx)

Platform is VS.NET 2003 and i am trying to design an application with
Forms

What is wrong here i didnt get it.. is there something i am missing?

..
..
../** STRUCTURE PROTOTYPE **/
struct task_node {
int task_id;
bool isserved;
double exec;
double phas;
double peri;
double dead;
double start_after;
double end_before;
double exec_remaining;

};
....
struct task_node *task_narr ; //Stands for TASK_NodesARRay

....

task_narr = new (nothrow) task_node [TASK_INSTANCES] ;

/** TASK_INSTANCES is some integer variable. i need to create an array
of "struct task_node" of size [TASK_INSTANCES] **/

for( thistask=0; thistask<39; thistask++ )
{
thisjobs = (int)HYPERPERIOD/(int)dperi_arr[thistask];
for( counter=0; counter<thisjobs; counter++)
{
task_narr[(thistask*thisjobs)+counter].task_id = thistask;
task_narr[(thistask*thisjobs)+counter].start_after =
(dperi_arr[thistask]*counter);
task_narr[(thistask*thisjobs)+counter].end_before =
(dperi_arr[thistask]*counter)+ dperi_arr[thistask];
task_narr[(thistask*thisjobs)+counter].dead = ddead_arr[thistask];
.....
..... /** Initializations.. But it seems that none is initialized.
}

DEBUG info:

-task_narr {task_node} { task_id=<undefined value> isserved=<undefined
value> exec=<undefined value> ...} task_node*

WHY VALUES ARE UNDEFINED????

WATCH info:

For. Example: watching "task_narr[0].task_id" is said to be :

"task_narr[0].task_id error: index '0' out of bound for pointer/array
'task_narr' "

WHAT DOES THIS MEAN? CANT I REFERENCE MY DYNAMIC DATA PILE AS IF IT IS
AN ARRAY? (it has been possible in C++ for zillion years..what is the
problem here? i am going mad..and i need urgent help

AND IT GIVES NO LINKING NO COMPILATION blah.blah. ERROR..THE FORM WORKS
BUT IT IS NOT DOING WHAT IT SUPPOSED TO DO. AND THE REASON IS:
-task_narr {task_node} { task_id=<undefined value> isserved=<undefined
value> exec=<undefined value> ...} task_node*
UNDEFINED VALUES ABOVE.

I HAVE ALSO TRIED malloc AND calloc AND RESULT IS THE SAME

Thanks

Mar 16 '06 #1
1 1832
os********@gmail.com wrote:
Platform is VS.NET 2003 and i am trying to design an application with
Forms
That's basically irrelevant here.
What is wrong here i didnt get it.. is there something i am missing?
I don't know what you're missing, but we're missing significant portions
of your code. See FAQ 5.8.
.
.
./** STRUCTURE PROTOTYPE **/
struct task_node {
int task_id;
bool isserved;
double exec;
double phas;
double peri;
double dead;
double start_after;
double end_before;
double exec_remaining;

};
...
struct task_node *task_narr ; //Stands for TASK_NodesARRay
You don't need the 'struct' keyword here.

...

task_narr = new (nothrow) task_node [TASK_INSTANCES] ;

/** TASK_INSTANCES is some integer variable.
WHAT integer variable? What's its value?
i need to create an array
of "struct task_node" of size [TASK_INSTANCES] **/

for( thistask=0; thistask<39; thistask++ )
{
thisjobs = (int)HYPERPERIOD/(int)dperi_arr[thistask];
for( counter=0; counter<thisjobs; counter++)
{
task_narr[(thistask*thisjobs)+counter].task_id = thistask;
What's the value of the expression in the brackets?
task_narr[(thistask*thisjobs)+counter].start_after =
(dperi_arr[thistask]*counter);
task_narr[(thistask*thisjobs)+counter].end_before =
(dperi_arr[thistask]*counter)+ dperi_arr[thistask];
task_narr[(thistask*thisjobs)+counter].dead = ddead_arr[thistask];
.....
..... /** Initializations.. But it seems that none is initialized.
}

DEBUG info:

-task_narr {task_node} { task_id=<undefined value> isserved=<undefined
value> exec=<undefined value> ...} task_node*

WHY VALUES ARE UNDEFINED????
Why are you SHOUTING?

What's "undefined value"? What's "DEBUG info"?
WATCH info:

For. Example: watching "task_narr[0].task_id" is said to be :

"task_narr[0].task_id error: index '0' out of bound for pointer/array
'task_narr' "

WHAT DOES THIS MEAN? CANT I REFERENCE MY DYNAMIC DATA PILE AS IF IT IS
WTF is wrong with your CapsLock key?
AN ARRAY? [...]


As soon as you calm down, learn to use your keyboard correctly, and post
more information I am requesting, I can probably answer...

V
--
Please remove capital As from my address when replying by mail
Mar 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kimimaro | last post by:
hi I wonder if array can be work along with structure? Below are the declaration of my structure struct employee{ char ID; char Name; char Department;
0
by: Jeff | last post by:
Hi guys Mattias, thanx for answering my last question Well, I'm struggling with marshaling a struct that has **ptr to an array of arrays of struct. Why? I'm stuck with it 1. I need to know...
1
by: Betty | last post by:
When marshalling a char array in a structure from C to .NET, I get the following error: System.ArgumentException: Type could not be marshaled because the length of an embedded array instance does...
3
by: kd | last post by:
Hi All, I need to declare an array in a structure. The following gives an error at private char chararr = new char; ------------------------------------------------------ struct SimpleStruct {...
2
by: Ananas | last post by:
Hi, Please give me an idea how to send a static array from dll written on C++ to C# application. This is a C++ code: const SIGNATURE_LENGTH = 50; struct Info {
8
by: anon.asdf | last post by:
Hi! OK, lets try "array-copy": { char arrayA; arrayA = (char){1, 2, 3}; } it does *not* work since we're trying to make a fixed array-pointer arrayA, point to another location/address...
17
by: Ron Peterson (012ED25E) | last post by:
I ran into something like the following while looking into how the GNU MP library implements its mpz_t type. typedef struct { int len; char *buf; } foo; This is an interesting technique. ...
2
by: themadme | last post by:
hi, im trying to amke a dynamic struct array with in a struct. Im not entirely sure how to do so. would it be something like this struct foo { }
5
by: ctj951 | last post by:
I have a very specific question about a language issue that I was hoping to get an answer to. If you allocate a structure that contains an array as a local variable inside a function and return...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.