Pointer problem in c++

Hey guys i made a programe using pointer.At first it worked well but the problem is when i made a copy of it,the copied problem doesn't work.Can anybody help me to find why this is happening...?
Could you post your code in here, so we can see what might have went wrong?
#include<bits/stdc++.h>
using namespace std;
struct data{
int *p;
int len;
};

///-----------Operator
data uni(data a,data b);
data inter(data a,data b);
void show(vector<int> v);
bool searp(int g,data d);
void dshow(data d);
///---------------Process--------
void Result(vector<char> &ch,vector<data>&vv,data a,data b,data c);
void popd(vector<data>&v);
int alen,blen,clen;
int main(){
data nn,aa,bb,cc,tmp;
int x[67]={1,3,5},*p,y[33]={2,3,4,5,6},z[87]={2,3,4,6,8},*q,top,*r;
char ttt[9]={'a', 'b', 'c', '&', '|'};
vector<char>ccc(ttt,ttt+5);vector<data>dd;
aa.p=x;bb.p=y;aa.len=3;bb.len=5,cc.p=z;cc.len=5;
Result(ccc,dd,aa,bb,cc);
dshow(dd[0]);

}

///--------------Operator----------------------
data uni(data a,data b){
data x;
int len,i,slen;
x.len=0;
slen=(a.len<=b.len)?a.len-1:b.len-1;

x.p=new int;
bool big;
if(a.len>=b.len){
len=a.len;
big=true;
}
else{
len=b.len;
big=false;
}
for(i=0;i<len;i++){
if(i>slen){
if(big){
if(!searp(*(a.p+i),x)){
*(x.p+x.len)=*(a.p+i);
x.len++;
}
}
else {
if(!searp(*(b.p+i),x)){
*(x.p+x.len)=*(b.p+i);
x.len++;
}
}
}
else{
if(!searp(*(a.p+i),x)){
*(x.p+x.len)=*(a.p+i);
x.len++;
}
if(!searp(*(b.p+i),x)){
*(x.p+x.len)=*(b.p+i);
x.len++;
}
}
}
return x;
}
data inter(data a,data b){
data inters;
int len,slen=(a.len<=a.len)?a.len-1:b.len-1,i;
inters.len=0;

inters.p=new int;
bool big;
if(a.len>=b.len){
len=a.len;
big=true;
}
else{
len=b.len;
big=false;
}
for(i=0;i<len;i++){
if(big){
if(searp(*(a.p+i),b)){
*(inters.p+inters.len)=*(a.p+i);
inters.len++;
}
}
else{
if(searp(*(b.p+i),a)){
*(inters.p+inters.len)=*(b.p+i);
inters.len++;
}
}
}
return inters;
}
bool searp(int g,data d){
int i;
for(i=0;i<d.len;i++){
if(*(d.p+i)==g){
return true;
}
}
return false;
}
void dshow(data d){
int i;
for(i=0;i<d.len;i++){
cout<<*(d.p+i)<<" ";
}
}

void Result(vector<char> &ch,vector<data>&vv,data a,data b,data c){
int i,len=ch.size(),tmlen;
data tt;
for(i=0;i<len;i++){
if(isalpha(ch[i])){
if(ch[i]=='a'){
vv.push_back(a);
}
else if(ch[i]=='b'){
vv.push_back(b);
}
else{
vv.push_back(c);
}
}
else{
if(ch[i]=='&'){
tt=inter(vv[vv.size()-1],vv[vv.size()-2]);
popd(vv);
vv.push_back(tt);
}
else if(ch[i]=='|'){
tt=uni(vv[vv.size()-1],vv[vv.size()-2]);
popd(vv);
vv.push_back(tt);
}
}
}///end of for loop
}
void popd(vector<data> &v){
v.pop_back();
v.pop_back();
}
Topic archived. No new replies allowed.