Solved

question about '\0'

Posted on 2003-11-23
6
333 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

839 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