title: c++: How to pass a raw string to a function like evaluate( "2+2\0+2" )?
body: <p>EDIT:: <code>std::string infix="2+2\0+2";</code> how to pass it to the function <code>evaluate(std::string s){cout &lt;&lt; s}</code>?  => 2+2+2 ?</p>
  
  <p>EDIT2:: <code>\0</code> is a <code>NULL</code> character; my function to check grammar reads every character from string and if it is different than numeric or operator it throws an exception. I would like to read null character and throws an exception, but <code>evaluate("2+2\0+2")</code> returns <code>4</code>. </p>
  
  <hr>
  
  <p>I am writing a simple calculator in c++11 with tests, supporting an infix notation.</p>
  
  <p>And I have a function <code>int evaluate( const std::string &amp; infix )</code> which calculates the result from my string (i.e. <code>evaluate( "((-3+--4*-(-19+5)))" )</code> returns <code>53</code>). And everything works just fine until...</p>
  
  <p>When I create some tests I can write <code>ASSERT_EQ(6, evaluate("2+2+2"))</code>. But when I write <code>ASSERT_EQ(6, evaluate("2+2\0+2")</code> everything goes wrong (this should throw an <code>exception</code> but it returns <code>4</code>).</p>
  
  <p>So how to pass an array of characters into a function, not knowing it size and having null characters inside of it? When <code>const char cstr[] = "2+\0+2"; evaluate(cstr);</code> does not send a full array :(</p>