2
votes
    long long int ** A = new long long int * [N];
    for ( long long int i=0; i<N; i++)
    {A[i]=new long long int[N];}

why does this lead to this warning: warning C4244: 'initializing' : conversion from '__int64' to 'unsigned int', possible loss of data

Is it not possible to have a long long int 2d dynamic array?

2
What is the type of N?André Puel
You want to have 2^64 * 2^ 64; that is an array with 2^128 elements. I doubt the whole world has enough memory to hold your array.Marius Bancila
hmm i see @MariusBancila thank youEzz
@Marius Bancila: How can you say how many elements are there without knowing the value of N?AnT

2 Answers

4
votes

The warning you are getting has absolutely nothing to do with the fact that your array consists of long long elements. The warning is issued either for your i variable or for your N. Most likely it is N that's causing the problem. What is N? How is it declared? I suspect it is also a long long.

In C++ language the type that is used for specifying memory sizes (and, incidentally, array sizes and indices) is called size_t. Apparently on your platform size_t is synonymous with 32-bit unsigned int type (32 bit platform?). The compiler is trying to convert your N, which is apparently a 64-bit type, to size_t and that triggers the warning.

In any case, there's absolutely no reason to insist on using long long for i or for N. Choose a more reasonable type for both (or convert N to that type) and the warning will disappear.

0
votes

try this

  #include<iostream>
#include<stdio.h>
using namespace std;

int main(int argc, char *argv[]) {
        int N=10;
        int i;
        long long int **A=new long long int*[N];
        for(i=0;i<N;i++)
        {
                A[i]=new long long int [N];
        }
        A[2][5]=5;
        cout<<A[2][5]<<endl;
        for(i=0;i<N;i++)
                delete []A[i];
        delete [] A;
        return 0;
}

works for me no warning even with -Wall