0

#include<iostream.h>
struct rectInfo{
float height ;
float width;
float area;
float perimeter;
};
/* write a function void gendata(rectInfo * r)to generate and assing values to
the height and width member of r(value should be b\w 1 - 20 )*/
void gendata(rectInfo * r)
{


}

2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by jonsca
0

plz help me. how to passs strutre to an arry &
write a function void gendata(rectInfo * r)to generate and assing values to
the height and width member of r(value should be b\w 1 - 20 )

0

how to passs strutre to an arry

Aside from having to strain my eyes to read that, what do you mean? How to make an array of structs?

0

Use new to create a pointer to a structure in main

rectinfo * rinfo = new rectinfo;

then just pass it in.

0

/* i wrote this program in c++ but how to initialize the height ,and width. using this code */
#include<iostream.h>
#include<conio.h>

struct rectInfo
{
int hight;
int width;
//int area;
//int parimeter;
void print()
{
cout<<hight<<" "<<width;
}
};

void main(rectInfo *r)
{

struct rectInfo * p=0;
p->hight=6;
p->width=5;

}

0

You don't have a function anything like the one in your requirement.

Main always returns an int, and certainly does not take your struct as an argument. I said create an instance of your struct in main.

You don't have to use "struct" in the line struct rectinfo *p=0; , it is required in C but not in C++.

Also note that you're trying to write values into a null pointer when you say p->height = 6; etc.

Also, please use code tags [code] //code goes here [/code].

Honestly, I'd say read over whatever resources you have, and start over again with it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.