I need a poniter to each variable for the structure but it seems because i have made a loop around the stuct it won't let me pass any variables outside of the loop. ( i hope i have made sence), is there a way to pass variables outside of the loop using pointers? or is there another way?.
Code:
#include <stdio.h>
#include <iostream>
#include <fstream>
struct product
{
int item;
char des[256];
int qty;
};
int main(int itemN, int qtyN, char ans, int *b)
{
do {
char items[256];
cout<<"\nPlease enter the item description > ";
cin.getline(items,256);
cout<<"Please enter the item number >";
cin>> itemN;
cout<<"please enter the quanity counted >";
cin>> qtyN;
product descrip;
product *ptr;
descrip.item=itemN;
descrip.qty=qtyN;
descrip.des=items;
ptr=&descrip;
cout<<"\nThis is the data you have entered\n";
cout<<"\nItem description > "<< descrip.des;
cout<<"\nItem > "<< descrip.item;
cout<<"\nQuantity > "<< descrip.qty <<"\n";
cout<<"\nIs this correct (Y/N) > ";
cin>> ans;
cin.get();
cout<< ptr;
} while ( ans=='n' );
ofstream a_file;
a_file.open("stores.dat",ios::app);
cin.get();
return 0;
}