View Single Post
  #1 (permalink)  
Old December 2nd, 2006, 05:18 PM
XeeTu XeeTu is offline
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to XeeTu
Default error with pointer code

hello, this is a code that was in the tutorial that i was following. This code explains how pointers work. I am using visual c++ .net 2003 to code this. This is the only code that i am having trouble with so far, every other code in the tutorial works fine. I checked and rechecked everything multiple times but cannot figure out what the error may be.

This is how it is listed in the tutorial and it is working perfectly for them and the tutorial also uses the same software which is visual c++ .net 2003.





#include <iostream>

using namespace std;

void main()
{
    int *ptr;

    ptr = new int[5];

    *ptr = 5;
    ptr[1] = 10;
    ptr += 2;
    *ptr = 15;
    ptr -= 2;

    for (int i = 0; i < 5; i++)
    {
        cout << ptr[i] << endl;
    }

    delete ptr;
}




I am getting error of error LNK2005: _main already defined in pointers.obj

and error

fatal error LNK1169: one or more multiply defined symbols found



Reply With Quote