ARM Technical Support Knowledge Articles

MODIFYING A STRUCT USING POINTERS

Applies to: C166 C Compiler

Answer

QUESTION

Help. I'm using C166 and I'm having trouble modifying a local structure using pointers I pass to other functions. Can you give me an example of how to do this?

ANSWER

The following program demonstrates creating a local structure and passing a pointer to it to other functions.

struct myst
{
int a;
int b;
int c;
int d;
};

void func_a (
  struct myst *x)
{
x->a = 0xFF00;
}

void func_b (
  struct myst *x)
{
x->b = 0x00FF;
}

void main (void)
{
struct myst xxx = { 1,2,3,4 };

func_a (&xxx);
func_b (&xxx);

while (1);
}

Article last edited on: 2004-05-16 17:12:42

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential