can someone teach me how to use pointer in this program??
i dont know if what i did in this program is correct. can you tell me how to use pointers here.thanks!

#include<stdio.h>
#include<iostream.h>


struct fruits
{
	int apple;
	int banana;
	int orange;
	int jackfruit;

} fruit;

	int shape;
	int color;
	int texture;

void main()
{
	struct fruits *pfruit;
	pfruit=&fruit;

	cout<<"Enter the number of your choice for shape: [0] round/ [1] oblong"<<endl;
	cin>>inputFruits();
	cout<<"Enter the number of your choice for color: [0] green/ [1] yellow/ [2] red/ [3] orange"<<endl;
	cin>>inputFruits();
	cout<<"Enter the number of your choice for texture: [0] smooth/ [1] rough"<<endl;
	cin>>inputFruits();

}

void inputFruits(struct fruits *pfruit)
{
	if(shape==0)
	{
		cout<<"round"<<endl;
		cin>>shape;
	}
	else
	{
		cout<<"oblong"<<endl;
		cin>>shape;
	}
	if(color==0)
	{
		cout<<"green"<<endl;
		cin>>color;
	}
	if(color==1)
	{
		cout<<"yellow"<<endl;
		cin>>color;
	}
	if(color==2)
	{
		cout<<"red"<<endl;
		cin>>color;
	}
	if(color==3)
	{
		cout<<"orange"<<endl;
		cin>>color;
	}
	if(texture==0)
	{
		cout<<"smooth"<<endl;
		cin>>texture;
	}
	else
	{
		cout<<"rough"<<endl;
		cin>>texture;
	}
	
}

void identifyFruits(struct fruits *pfruit)
{
	if(shape==0)
	{
		if(color==2)
		{
			if(texture==0)
			{
				cout<<"Apple"<<endl;
				cin>>pfruit->apple;
	}}}

	if(shape==1)
		{
			if(color==1)
			{	
				if(texture==0)
				{
					cout<<"Banana"<<endl;
					cin>>pfruit->banana;
	}}}

	if(shape==0)
		{
			if(color==3)
			{
				if(texture==0)
				{
					cout<<"Orange"<<endl;
					cin>>pfruit->orange;
	}}}
	if(shape==1)
	{
		if(color==0)
		{
			if(texture==1)
			{
				cout<<"Jackfruit"<<endl;
				cin>>pfruit->jackfruit;
	}}}


}
Comments
*Points To siddhant3s*
23Posts, Void main? non standard headers.

Don't bother using text tags for yout text, thats not what its for. it stands for Latex, a Mathematical Notation Syntax.

Secondly, we don't know what your program is supposed to do and what it is or is not doing, so we can't help you.


Chris

Sorry..
In this program you will enter the number of your choice if 0 (round) or 1 (oblong) for the shape.
For the color 0(green), 1(yellow), 2(red), 3(orange)
For the texture 0(smooth) or 1(rough).
It will identify the type of fruit..
example if you input 0 for shape, 2 for color, and 0 for texture it will tell you that fruit is an apple

>can someone teach me how to use pointer in this program??i don't know if what i did in this program is correct. can you tell me how to use pointers here.thanks!

Please Be specific.
This is not a teaching classroom dear. You must read your text book and come to us with very specific questions.
We, can tell you how to use pointers but how the hell are we suppose to explain you the whole program. Do you think it is feasible?

Secondly, DO NOT USE VOID MAIN() http://cppdb.blogspot.com/2009/02/should-i-use-void-main-or-int-main-or.html

use #include<iostream> and #include<cstdio> Use a new compiler not a old one(http://cppdb.blogspot.com/2008/10/why-you-shouldnt-use-you-use-old-c.html)

And thirdly, The program contains lot of (trivial) errors. We are not going to debug them for you. For your curiosity, there's a error in the cin>>inputfruits() You cannot cin to function.

So, please correct the errors and read the book. Then asks what is troubling you.

Comments
You're always making good advices !!
This article has been dead for over six months. Start a new discussion instead.