0

In program that put data by fgets to char array, array is declared like that:

char line[0x400];

Is such declaration allow to input more data to array? I dont understand why not to use:

char line[400];
Don Kielon
  • 31
  • 4
  • 1
    "Is such declaration allow" – yes. All numbers are: `0700`, `'B'`, `42`. They are all just numbers. – Jongware Nov 07 '18 at 23:37
  • 2
    Possible duplicate of [What do numbers using 0x notation mean?](https://stackoverflow.com/questions/8186965/what-do-numbers-using-0x-notation-mean) – hpm Nov 08 '18 at 00:28

2 Answers2

1

Values starting with 0x are interpreted as hexadecimal values in C and C++. So

char line[0x400];

declares an Array of char of 1024 elements and

char line[400];

an Array of char of 400 elements.

Swordfish
  • 12,971
  • 3
  • 21
  • 43
0

0x400 is a hexadecimal representation. Usually, when you see a number in this format 0x<number> it means the number is represented as an hexadecimal.

Also, https://www.wolframalpha.com/input/?i=dec(0x400). So yes, the first array is (624 positions) bigger.

hess
  • 76
  • 5
  • You can also check the conversion here: https://www.wolframalpha.com/input/?i=dec(0x400) – hess Nov 07 '18 at 23:42