Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

c++ string and operator[]

$
0
0

The difference between operations:

  1. string s; s[0]= 'a'; cout<<s; gives nothing as output.
  2. string s; s+= 'a'; cout<<s; output: 'a'.
  3. string s= " "; s[0]= 'a'; will also print 'a'

Can anyone please explain this behaviour ?


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>