why is this code not working?

so i just want to know why this code is not working...i know the problem is in the function createUniqueVector...but after looking and looking i still can't say why is not working...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  #include <vector>


std::vector<int> CreateUniqueVector(const int* firstItem, const int* lastItem)
{
std::vector<int> vReturn;

int dup = 0;

	for (const int* curItem = firstItem; curItem != lastItem; ++curItem )
        {
		for (const int* chkItem = firstItem; chkItem != lastItem ; ++chkItem)
			{if ((chkItem != curItem) && (*chkItem == *curItem))
			     {
			         dup += 1;
			     }
		if (dup = 0)
        {
            vReturn.push_back(*curItem);
        }
			}
        }

        return vReturn;
}

const int col = 5;
int Array [6][5]= {{1,2,3,4,4,},
                      {7,4,5,7,6,},
                      {4,0,7,9,0,},
                      {4,5,5,9,0,},
                      {4,5,9,9,0,},
                      {1,1,1,1,1,},

                                  };
  int main()
  {
      std::vector <int> iv;
      std::vector <int> v;
      for (int i = 0; i < col ; i++)
      {
          iv = CreateUniqueVector(&Array [i][0], &Array[i][col-1] );
      }

    for (int k = 0; k < iv.size(); k++)
    {
        v.push_back (iv[k]);
    }
for (int i = 0; i<v.size(); i ++)
{
     std::cout<< v[i] <<"," ;
  }
      
std::cout<<std::endl<<"size of iv is ..." <<iv.size();

return 0;
  }





On line 17:
if (dup = 0) // This assigns 0 -> if (dup == 0) // Note: ==
On line 17 you use = instead of ==.
Please explain the "not working".
thats right coder777 and Peter87...those petty petty things...thanks guys
Topic archived. No new replies allowed.