Returning a '/n' character in c++ : <p>I am doing a homework assignment for my c++ class, and I can't seem to figure out what I am doing wrong.</p>

<p>Here are the directions:</p>

<p>Exercise: read02</p>

<p>Description</p>

<p>In this exercise, you will create a function to fetch a character from a string, but only if the specified index is in range. If it is out of range, return the newline character.</p>

<p>Function Name</p>

<p>read02</p>

<p>Parameters</p>

<pre><code>str: a std::string
index: a size_t
</code></pre>

<p>Return Value</p>

<p>The char stored at index in str, unless index is out of range, then \n.</p>

<p>Examples</p>

<pre><code>std::string data = "hello";
size_t i = 3;
char x = read02(data, i);
</code></pre>

<p>Hints</p>

<p>String Documentation
Remember to include the header file.
size_t requires the cstdlib header file.
size_t is unsigned (only includes values that are >= 0).
'\n' is the character constant for the newline character.</p>

<p>Here is what I have:</p>

<pre><code>#include &lt;string&gt;
#include &lt;cstdlib&gt;

char read02(std::string str, size_t index){
    size_t i;

    for( i = 0; i &lt; str.size(); i++){
        if(index &gt; 0 &amp;&amp; index &lt; str.size()){
            return str[index];
        }
        else{
            return '/n';
        }
    }
    return 0;
}
</code></pre>

<p>And here is the error I am getting:</p>

<pre><code>error: multi-character character constant [-Werror=multichar]
             return '/n';
</code></pre>

<p>Any explanation as to why I'm getting this error and how to fix it would be greatly appreciated.</p>

<p>Thanks!</p>
