This is a discussion on Reason for Compiler Error within the C and C++ forums, part of the Programming Talk category; Why is the compiler throwing error if I try to assign some value to the terminator of char array namely '\...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Why is the compiler throwing error if I try to assign some value to the terminator of char array namely '\0’? I want to know the reason for the error. Also let me know whether I can compare the terminator of char array namely '\0'using operator == or will it also throw error. If so why is it?
|
|
|||
|
It is important to understand the concept of char arrays for your problem. Strings in C programming are represented as char arrays. Char array is terminated by a null character called as terminator denoted as '\0' and it has a char value 0.So only you cannot assign any value to the terminator of char array namely '\0’. Since you tried that you got compiler error. The terminator is automatically placed at the end of string by C programs and users have to allocate a space for this also taking consideration of this. As explained before since '\0' in a char array is null value no comparison of the terminator of char array namely '\0' using operator == is allowed.
|
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| web.config gives error if i store string that contin "&" character in appSettings | mahehs_k_anjani | Microsoft .NET | 2 | 09-06-2006 06:21 AM |
| Comp.Sys.Acorn.FAQ part 2 of 4 | Paul Vigay | Tech FAQ | 0 | 05-31-2004 09:00 PM |
| Apple II Csa2 FAQs: Error List, Part 8/25 | rubywand@swbell.net | Tech FAQ | 0 | 05-04-2004 10:01 AM |
| Comp.Sys.Acorn.FAQ part 2 of 4 | Paul Vigay | Tech FAQ | 0 | 04-30-2004 09:00 PM |
| Kerberos FAQ, v2.0 (last modified 8/18/2000) | Ken Hornstein | Tech FAQ | 0 | 04-17-2004 08:28 AM |