Exforsys

Online Training

Reason for Compiler Error

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 '\...


Go Back   Exforsys > Programming Talk > C and C++

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-05-2007, 06:32 PM
Senior Member
 
Join Date: Apr 2006
Posts: 141
Adrian is on a distinguished road
Question Reason for Compiler Error

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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-10-2007, 09:20 AM
Senior Member
 
Join Date: Apr 2006
Posts: 139
Ralph is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

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


All times are GMT -4. The time now is 11:21 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.