Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can I pass an array pointer to a function
    primarykey
    data
    text
    <pre><code>#include &lt;fstream&gt; #include &lt;iostream&gt; #include &lt;sstream&gt; #include &lt;string&gt; #include &lt;vector&gt; using namespace std; typedef vector &lt;double&gt; record_t; typedef vector &lt;record_t&gt; data_t; int sorted(int *data,int max_record_size) { } int main() { // Here is the data we want. data_t data; // Here is the file containing the data. Read it into data. ifstream infile( "sort.txt" ); infile &gt;&gt; data; // Complain if something went wrong. if (!infile.eof()) { cout &lt;&lt; "Fooey!\n"; return 1; } infile.close(); // Otherwise, list some basic information about the file. cout &lt;&lt; "Your CSV file contains " &lt;&lt; data.size() &lt;&lt; " records.\n"; unsigned max_record_size = 0; for (unsigned n = 0; n &lt; data.size(); n++) if (max_record_size &lt; data[ n ].size()) max_record_size = data[ n ].size(); cout &lt;&lt; "The largest record has " &lt;&lt; max_record_size &lt;&lt; " fields.\n"; int i; for (i=0; i &lt;= max_record_size; i++) { cout &lt;&lt; "your data contains " &lt;&lt; data[ 0 ][ i ] &lt;&lt; ".\n"; int temp[max_record_size]; sorted(&amp;data,max_record_size); //cout &lt;&lt; "Your sorted data contains" &lt;&lt; sorted [0] [i] &lt;&lt; ".\n"; } cout &lt;&lt; "Good bye!\n"; system("PAUSE"); return 0; } </code></pre> <blockquote> <p>cannot convert <code>data_t*' to</code>int*' for argument <code>1' to</code>int sorted(int*, int)'</p> </blockquote> <p>Im trying to pass the pointer of my data which should be an array containing my list of numbers to my sort function what exactly am I doing wrong and can you please explain in detail so I can understand it, thanks!</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.
    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