Solved

question about '\0'

Posted on 2003-11-23
6
332 Views
Last Modified: 2010-05-18
When I enter a char array of numbers will I need to add the \0 char as you do with words?
0
Comment
Question by:buckeyes33
  • 4
6 Comments
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9806670
The \0 character only specifies the logical end of a, let's use your term, "word." We can have a character array that is 80 characters in length but the "word" would occupy up to just before this \0 character.
So char arr[80] = "Hello"; would make this happen:
arr [0][1][2][3][4][5][6][7][8]...
      'H' 'e' 'l'  'l'  'o''\0' *  *  * ...
(all *'s stand for garbage data).
If using this argument to answer the question above, then, no you don't have to include the '\0' character because it does not necessarily clarify anything.
0
 
LVL 4

Accepted Solution

by:
n_fortynine earned 125 total points
ID: 9806760
Well, unless you want to manipulate the entire array as a number itself using some string-related methods. In that case, you should. :)
0
 
LVL 9

Author Comment

by:buckeyes33
ID: 9806779
Yes i am using it as a string.  So I will want to use it.  I thought so but I was not completly sure.  Thanks.
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Expert Comment

by:harishg2
ID: 9816526
no need of it because string itself means that array of characters with a NULL '\o'  at the end of it .
 thank u very much
0
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9818446
>>no need of it because string itself means that array of characters with a NULL '\o'  at the end of it .
that is, IF some other process did it FOR you, i.e. if you use some streams to put data in there then yes, you do not have to manually set the null character. BUT, if I want to use an array of numbers as a whole number itself I DO want to do that. An array of characters which are numbers are not necessarily a string UNTIL you make it so (or have somebody done it for you making you think it's done under every circumstances).

FYI, it's '\0' (zero) not '\o'
0
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9818454
>>are not necessarily
should read : is not necessarily
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question