0
   unsigned __int8 result[]= new unsigned __int8[sizeof(username) * 4];

IntelliSense: initialization with '{...}' expected for aggregate object

TQCopier
  • 81
  • 1
  • 1
  • 4

4 Answers4

1

The types are not the same; you cannot initialize an array with a pointer.

new unsigned __int8[sizeof(username) * 4]; returns a unsigned __int8*, not unsigned __int8[]

change your code to

unsigned __int8* result = new unsigned __int8[sizeof(username) * 4];
tenfour
  • 36,141
  • 15
  • 83
  • 142
  • what if i want to return result how can i do that!? – TQCopier Feb 09 '11 at 11:22
  • @Kevin i mean if result is = 5; i want to return 5 , coz i cant return reslut while it's pointing for something else , i need to get it's value from the memory or something – TQCopier Feb 09 '11 at 11:35
  • @TQCopier Do you mean the value pointed by `result`? In that case you cold do this: `return *result;` which returns the value pointed by `result`. – Kevin Feb 09 '11 at 14:08
0
unsigned __int8 *result = new unsigned __int8[sizeof(username) * 4];
Thomas
  • 174,939
  • 50
  • 355
  • 478
0

new returns a pointer, not an array. You should declare

unsigned __int8* result = .... 
Francesco
  • 3,200
  • 1
  • 34
  • 46
0

here, result is an array of __int8, so you can't assign one value into the entire array. You actually want:

unsigned __int8* p_result = new unsigned __int8[sizeof username * 4];
Tony Delroy
  • 102,968
  • 15
  • 177
  • 252