Member Avatar for HASHMI007

#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)
{


}

Member Avatar for HASHMI007

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 )

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?

Member Avatar for HASHMI007

sory bro i mean ho to pass structure to a function as pointer

Use new to create a pointer to a structure in main

rectinfo * rinfo = new rectinfo;

then just pass it in.

Member Avatar for HASHMI007

/* 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;

}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.