Note that there are some explanatory texts on larger screens.

plurals
  1. POquestions regarding char* and char[] basics
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1704407/what-is-the-difference-between-char-s-and-char-s-in-c">What is the difference between char s[] and char *s in C?</a><br> <a href="https://stackoverflow.com/questions/2938895/difference-between-char-a-string-char-p-string">Difference between char a[]=&ldquo;string&rdquo;; char *p=&ldquo;string&rdquo;;</a> </p> </blockquote> <p>Firstly, i would like to ask where can i learn all the basics of char* and char[].</p> <p>Most of the time i find myself struggling with how to compare and how to declare.</p> <p><strong>Example 1 :</strong></p> <pre><code> char *test = "hello world"; </code></pre> <p>This will produce the following warning at compilation : </p> <pre><code> warning: deprecated conversion from string constant to ‘char*’ </code></pre> <p><strong>Example 2 :</strong></p> <pre><code> vector&lt;char*&gt; test2; test2.push_back("hello world"); </code></pre> <p>This will produce an error of copying a string.</p> <p>So the solution i come up with is :</p> <p>(is this correct?)</p> <pre><code> vector&lt;char*&gt; test3; char *str1 = "hello world" test3.push_back(str1); </code></pre> <p>Thanks in advance! :)</p> <p>============================================</p> <p>Two good reads provided by people here :</p> <p><a href="https://stackoverflow.com/questions/1704407/what-is-the-difference-between-char-s-and-char-s-in-c">What is the difference between char s[] and char *s?</a></p> <p><a href="https://stackoverflow.com/questions/2938895/difference-between-char-a-string-char-p-string">Difference between char a[]=&quot;string&quot;; char *p=&quot;string&quot;;</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload