Note that there are some explanatory texts on larger screens.

plurals
  1. POusing a string array in a function C++
    primarykey
    data
    text
    <p>this question should be easy and straight forward, but after searching online, I couldn't find an answer. might because the question is just too simple.<br> following code is from <a href="http://www.cplusplus.com/reference/cctype/tolower/" rel="nofollow">cplusplus.com</a>. it's a function of making a string lowercase. I was intended to do something similar. </p> <pre><code>/* tolower example */ #include &lt;stdio.h&gt; #include &lt;ctype.h&gt; int main () { int i=0; char str[]="Test String.\n"; char c; while (str[i]) { c=str[i]; putchar (tolower(c)); i++; } return 0; } </code></pre> <p>and what I made is this:</p> <pre><code>void search(string A[], string B[], int k) { int temp; for(int j = 0; j &lt;= 4; j++) { for(int i = 0; i &lt;= k; i++) { string str (A[i]); int h = 0; char lstr[] = B[j]; char c; while (lstr[h]) { c = lstr[h]; putchar (tolower(c)); h++; } string key (B[j]); ..... </code></pre> <p>this part of the code is in a for loop. B[j] is a string array. <br> Visual Studio informed me that <em>char lstr[] = B[j];</em> part is not right, the error message is: <br> <em>Error: initialization with '{...}' expected for aggregate object.</em><br><br> I think the problem is that I didn't use the correct syntax of using a string array in a function. something should be done for B[j], in order to make it a char array. I couldn't figure it out.<br> is that something about pointer? sorry I haven't learn pointer yet.<br><br> does my question make sense for you? any help is greatly appreciated!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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