Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to read a values from the structure in C

Status
Not open for further replies.

hemanthjv

Newbie level 4
Joined
Apr 24, 2013
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,322
#include<stdio.h>
#define msize 4096

struct memory
{
int a[msize];
};

void main()
{
struct memory m;
m.a[0]=250; // temperature value of 25,0
m.a[4]=01; // heater status OFF
m.a[8]=240; // temperature value of 24,0
m.a[12]=00; // heater status ON
m.a[16]=220; // temperature value of 22,0
m.a[20]=00; // heater status ON
read(&m
HTML:
);

}

void read(struct memory m)
{
int i;
for(i=0;i<sizeof(msize);i++)
{
scanf("%d", m.a);
}
}


the code is showing error in void read function as first defined here .

Please some one also help me to convert this read value to ASCII ??
 

the code is showing error in void read function as first defined here .

you have to declare function prototype at the top of the code [functions should be declared before using it]. So, place the function void read(struct memory m) before main function where you called this function from main.

#define msize 4096

Which PIC you are using? do you have such amount of data memory in your PIC MCU (4 KB).

suggestion: google struct in C
 

you might solve the errors like following:

#include<stdio.h>
#define msize 4096

struct memory
{
int a[msize];
};

void read(struct memory m)
{
int i;
for(i=0;i<sizeof(msize);i++)
{
scanf("%d", &m.a);
}
}


int main()
{
struct memory m;
m.a[0]=250; // temperature value of 25,0
m.a[4]=01; // heater status OFF
m.a[8]=240; // temperature value of 24,0
m.a[12]=00; // heater status ON
m.a[16]=220; // temperature value of 22,0
m.a[20]=00; // heater status ON
read(m);

}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top