|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
||||
|
||||
|
Differences in index arrays
My book mentions that I can delcare an array like this:
char line[5] = "Hello"; Or, like this: char line[] = "Hello"; I understand the compilar will automatically pick out what number should be in the [] but does this take more memory? My book is strong on "Good coding ediket" (or something). Does it use less memory by telling the array the index #er? Or does it not matter? Thanks in advance. -andy P.S. e-d-i-c-k-e-t is spelled wrong cause the forum picked up the word "d-i-c-k" in it. LOL! |
|
#2
|
||||
|
||||
|
char line[] = "hello"; will pick exactly the number of characters required to store the string (i.e.) 6 characters (5 characters + the trailing null character to delimit the string). It does not take more memory than is required. While you're at it:
char line[5] = "hello"; This should really read: char line[6] = "hello"; You're omitting the trailing null character from the array otherwise. P.S. I think you mean e-t-i-q-u-e-t-t-e ![]() |
|
#3
|
||||
|
||||
|
I can't spell..I should be sent back to middle school.
__________________
hmmm... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Differences in index arrays |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|