1. ## initializing array .

Code:
`char arr[256]={'0'};`
it puts '0' in every cell
??

--
Mats

3. i remember that we could put in every cell of an array one value
by a similar way
??

4. Listen to matsp. You can find dozens of pages explaining this in google.

PS: Really sure it's '0' and not 0?

5. Originally Posted by transgalactic2
i remember that we could put in every cell of an array one value
by a similar way
??
Only to the value zero (not '0', that's the character representing the digit zero, commonly the value 48, but not guaranteed). For any constant other then zero, you will have to either enter all the 256 values [16 rows of 16, for example], or write code to fill in the values - e.g. use memset().

--
Mats

6. actually it was 0
but i though it was '0' because its a array of chars

not an array of integers

??

7. i cant put 0 into char array
its a number
??

8. Originally Posted by transgalactic2
i cant put 0 into char array
its a number
Then you can't put '0' in a char array either, since it is also a number (of type int, in fact).

9. the ascii value of 0 is NULL
so it puts NULL in every cell

and i can do this shortcut
only with NULL value

can i do
Code:
`char arr[256]={67};//the letter that 67 represenst`

10. Originally Posted by laserlight
Then you can't put '0' in a char array either, since it is also a number (of type int, in fact).
'0' is a char
not a number

11. Originally Posted by transgalactic2
the ascii value of 0 is NULL
so it puts NULL in every cell
The null character has a value of 0, and this is true with ASCII as well. However, the macro NULL is different in meaning from the null character, even though they are equal and may have the exact same value and type. Consequently, it is usually semantically wrong to say that "it puts NULL in every cell" unless you are talking about an array of pointers.

Originally Posted by transgalactic2
and i can do this shortcut
only with NULL value
This "trick" works with zero values, including NULL, because those elements of the array that are not explicitly initialised will then be zero initialised.

Originally Posted by transgalactic2
can i do
Yes, but you will end up with an array for which arr[0] has the value of 67 and the rest have the value of 0.

EDIT:
Originally Posted by transgalactic2
'0' is a char
not a number
No, '0' is an int, and the char type is an integer type.

12. ya i just tested it works with
Code:
`char arr[256]={67}`
but fills only arra[0] not all array other will be NULL

13. Code:
`char arr[256]={0};`
so if want to initialize arr without a loop
i can put only NULL char in them

14. You could simply write out 67 256 times

Or you could use memset().

15. Maybe even a for-loop, but memset is often more optimized. Or, if you don't mind a trailing NUL:

Code:
`char arr[] = "00000000000000000000000000000000000000000000000"...;`
BTW: NULL is "(void *)0", NUL is "(char)0".