You are not logged in. Please login at to post your questions!


end() string doest not have null character?

string s="string"; if(*s.end()=='/0') cout<<"he";

he doesnt come. Doesnt the string store null character in the end?

asked 09 Dec '18, 00:39

galavk's gravatar image

accept rate: 0%

The string you're using is an object of the string class (called std::string), it is not null-terminated (<string>). C-style strings on the other hand are null-terminated, they're basically character arrays terminated with a '\0' (<cstring>). For example,

char c[]="string";

The assert statement will not terminate the program as it evaluates to true.


answered 09 Dec '18, 02:32

ankitmaity's gravatar image

accept rate: 0%

edited 09 Dec '18, 02:34

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 09 Dec '18, 00:39

question was seen: 48 times

last updated: 09 Dec '18, 02:34