Hi aal,
I am trying to draw different shapes in BREW MP. it’s a mob OS by Qualcomm. The programming is in C.
The operation is I’ve to draw different shapes on screen based on the selected button. But before drawing the next shape I need to store the values of old shapes which I had drew. So I need to maintain data structure for each shapes. When I press particular button(say circle) after drawing that circle values need to be stored in linked list before drawing next shape.
I’ve taken a linked list after drawing each shape add it as a node to linked list then before calling new shape traverse this list n draw all available shapes.
for that i've bulit union inside a structure with type_def -
struct shapes{
-
int type_in_union;
-
union draw{
-
struct line lines;
-
struct ellipse ellipses;
-
struct rect rects;
-
struct polygon polygons;
-
-
}draw;
-
}shapes1;
-
-
-
-
-
struct line{
-
int sx,sy;
-
int ex,ey;
-
}line;
-
-
struct ellipse{
-
int cx,cy;
-
int wx;
-
int wy;
-
}ellipse;
-
-
struct rect{
-
int x,y;
-
int dx,dy;
-
}rect;
-
-
struct polygon{
-
int len;
-
struct point *points;
-
}poly;
-
-
struct point{
-
int x,y;
-
}points;
-
-
now i want to dump after each operation(each shape ) that structure into the linked list so that when next time before drawing any new shape i can call all the previous shapes i had drew using linked list .
for this i've declared a liked list -
struct Node{
-
struct shapes *shape;
-
struct Node *pNext;
-
struct Node *pPrev;
-
int type;
-
};
-
I am Trying to create nodes of structure -
insert_node(create_node(&shape_type,&a,&b,&x,&y));
-
-
void insert_node(struct Node *pNode)
-
{
-
-
struct Node *t;
-
struct Node *pTemp = NULL;
-
if(pStart == NULL)
-
{
-
pStart = pNode; /* Store address of the node as the start node */
-
return;
-
}
-
else
-
{
-
t=pStart;
-
while(t->pNext!=NULL)
-
{
-
t=t->pNext;
-
}
-
t->pNext=pNode;
-
pNode->pPrev=t;
-
}
-
}
-
-
struct Node* create_node(int *shape_type,int *a,int *b,int *x,int *y)
-
{
-
struct Node *pNode = NULL; // Pointer to the new node
-
pNode = (struct Node*)malloc(sizeof(struct Node)); // Allocate memory for node
-
pNode->pNext = NULL; // No next node yet
-
pNode->pPrev = NULL; // No previous node
-
pNode->type=*shape_type;
-
pNode->shape = create_record(&shape_type,&a,&b,&x,&y); // Create record and store address in node
-
return pNode;
-
}
-
create_record function -
-
struct shapes* create_record(int *shape_type,int *a,int *b,int *x,int *y)
-
{
-
struct shapes *shape=NULL;
-
-
if(*shape_type==LINE)
-
{
-
//struct shapes *shape=NULL;
-
shape = (struct shapes*)malloc(sizeof(struct shapes));
-
shape->draw.lines=createline(&shape_type,&a,&b,&x,&y);
-
}
-
return shape;
-
-
}
-
-
createline function -
struct line* createline(int *shape_type,int *a,int *b,int *x,int *y)
-
{
-
struct line *line1=NULL;
-
line1 = (struct line*)malloc(sizeof(struct line));
-
line1->start_x=*a;
-
line1->start_y=*b;
-
line1->end_x=*x;
-
line1->end_y=*y;
-
return line1;
-
}
-
-
Is It Right way to store the things into structures???????????
n also i wantt to retrieve the things how it can be done....??????
5 2299
I suggest you write a main(). Create a struct variable and create ints f various values. Then add the values to the struct variable. Next use printf to display the values you put in the variable.
Remember that you use the "." operator for struct variable members when you use the variable name and the "->" operator for the members when you use the address of a struct variable.
HI,
There is no main in this BREW SDK man... Its not giving any compilation error but giving error during run time..:(
Then you probably have a bad pointer value.
I suggest you step through the code using your debugger. When you find the line that fails and you can't fix it, then post again.
Probably not your problem, but you should always check if malloc failed.
Hey now its working fine ..:) Thanks for the Replies:)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Chris Ritchey |
last post by:
Hmmm I might scare people away from this one just by the title, or
draw people in with a chalange :)
I'm writting this program in c++, however I'm using char* instead of
the string class, I am...
|
by: dam_fool_2003 |
last post by:
friends,
I wanted to learn the various ways of inserting a single list. so:
Method 1:
#include<stdlib.h>
#include<stdio.h>
struct node
{
unsigned int data;
struct node *next;
|
by: Kieran Simkin |
last post by:
Hi all,
I'm having some trouble with a linked list function and was wondering if
anyone could shed any light on it. Basically I have a singly-linked list
which stores pid numbers of a process's...
|
by: Jonathan Bartlett |
last post by:
Just finished a new IBM DeveloperWorks article on linked lists, and
thought you all might be interested. It's not an introduction -- it
instead covers some of the more interesting aspects of...
|
by: Xarky |
last post by:
Hi,
I am writing a linked list in the following way.
struct list
{
struct list *next;
char *mybuff;
};
|
by: Dongsheng Ruan |
last post by:
with a cell class like this:
#!/usr/bin/python
import sys
class Cell:
def __init__( self, data, next=None ):
self.data = data
|
by: AZRebelCowgirl73 |
last post by:
This is what I have so far:
My program!
import java.util.*;
import java.lang.*;
import java.io.*;
import ch06.lists.*;
public class UIandDB {
|
by: Chris Thomasson |
last post by:
I was wondering if the 'SLINK_*' and 'SLIST_*' macros, which
implement a simple singly-linked list, will produce _any_ possible
undefined behavior:
____________________________
#include...
|
by: dmp |
last post by:
Where can I find programs related to linked list.
|
by: kalyan |
last post by:
Hi,
I am using Linux + SysV Shared memory (sorry, but my question is all
about offset + pointers and not about linux/IPC) and hence use
offset's instead on pointers to store the linked list in...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |