issue with pointers

my visual c++ 2012 fail to compile it.
error C2440: '=' : cannot convert from 'int *' to 'int'

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
  int firstvalue, secondvalue;
  int * mypointer;

  mypointer = &firstvalue;
  *mypointer = 10;
  mypointer = &secondvalue;
  *mypointer = 20;
  cout << "firstvalue is " << firstvalue << endl;
  cout << "secondvalue is " << secondvalue << endl;
return 0;
}
Last edited on
Aside from the weird tchar garbage I don't see anything wrong with this code. What line is giving you the error?
It looks fine to me, and compiled if I got rid of _tmain and the precompiled headers, though I wouldn't think those are related to the issue.
line 10 and :
int _tmain(int argc, _TCHAR* argv[])
created automatically with win32 console application project
There is nothing wrong with line 10.

Are you sure you posted the actual code that is giving you the error?


Also I typically select the "empty project" option. But whatever.
i resetart VS and it seems ok thanx.
Topic archived. No new replies allowed.