-2

I have:

void *abc;
int *abc2;

int someInt = 5;
int *intPtr = &someInt;
abc = intPtr;   // This line is ok without casting
abc2 = abc;     // Here will be an error without casting

Why is this?

Praetorian
  • 106,671
  • 19
  • 240
  • 328
abcde
  • 23
  • 4
  • 6
    [No error for me](http://ideone.com/gm9xYy), are you compiling the code as C++? Believe it or not, C and C++ are two different languages. – Praetorian Jan 09 '15 at 04:30
  • Can you provide your compiler output as well (ie: `gcc myFile.c -Wall`)? This will help. – Cloud Jan 09 '15 at 04:47

1 Answers1

2

In C language both assignments (both lines) are perfectly OK without casting.

The second line would produce an error in C++, but your question is tagged C. Your assertion about an error on the second line is false.

AnT stands with Russia
  • 312,472
  • 42
  • 525
  • 765