CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Array error and something else

    Hi. I get this message when trying to build the below code:

    c:\documents and settings\user\my documents\visual studio 2005\projects\lesson6\lesson6\lesson6.cpp(7) : error C2440: 'initializing' : cannot convert from 'int' to 'int [3]'
    There are no conversions to array types, although there are conversions to references or pointers to arrays




    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	int postOffice[3] = (0);
    
    return(0);
    }
    Now I got this code from the videos that I've been watching and they don't have

    Code:
    return(0);
    in their examples. They also don't declare main() as an int, but it still works fine for them. They are using Microsoft VS 2003, while I'm using Microsoft VS 2005 Express.

    I guess that my questions are:

    1. Is there a reason why it works fine for them but not for me?;

    2. and why do I get the above error code?

    Thankyou in advance for anyone that helps.

  2. #2
    Join Date
    May 2006
    Posts
    327

    Re: Array error and something else

    I think in that low-resolution video they actually have:
    Code:
    int postOffice[3] = {0};
    I hope this helps.

  3. #3
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: Array error and something else

    It does my good man! It does! (or girl... sorry haha)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured