Note that there are some explanatory texts on larger screens.

plurals
  1. POcreating a function to match a string in the main
    primarykey
    data
    text
    <p>This is a group assignment and it's become rather difficult to the point our professor has extended the project by 1 week. there are 50 stages/tests, we've only been able to reach up to stage 11 and then the function fails.</p> <p>this function is in our .cpp file (we're positive it's this function causing the problem's because when we change parts of it, it affects stage 11 which we've passed).</p> <pre><code>int segment::match(const char word[]) { int i; cout &lt;&lt; data[0]; data[0] == "OOP"; cout &lt;&lt; data[0]; for(i=0;i&lt;NUM_MAX;i++) { cout &lt;&lt; "word = " &lt;&lt; &amp;word[i] &lt;&lt; " data[i] = " &lt;&lt; data[i]; if(strstr(&amp;word[i],data[i])!= NULL) break; } return i==NUM_MAX ? 1 : i-1; </code></pre> <p>and from the main.cpp (provided to us as the assignment) this is the what we are trying to accomplish</p> <p>Passed test 11...</p> <pre><code>Your match( ) return value ----&gt; -1 Actual match( ) return value --&gt; -1 Press the ENTER key to continue... word = OOP data[i] = Failed while testing the match( ) function... Failed on test 12... Your match( ) return value ----&gt; -1 Actual match( ) return value --&gt; 1 Press the ENTER key to continue... You passed 11/50 tests... Your program is 22.00% complete! Your program still needs some work! Keep at it! </code></pre> <p>what the function is suppose to do is check for "oop" and if it isn't there it exits with -1, and if it is there it should return true with 1.</p> <p>I guess what I'm asking is how do I make that function that it returns both -1 and 1 in the proper order?</p> <p>If you would like access to the main.cpp and segement.cpp i can upload that as files somewhere because they're very long and I did not want to cram the post. </p> <p>Any help is appreciated, thank you.</p> <p><em><strong>EDIT</em>*</strong> Here is the full code that we have <a href="http://jsfiddle.net/h5aKN/" rel="nofollow">http://jsfiddle.net/h5aKN/</a></p> <p>The "html" section has the segement.cpp which is what we built. and the jscript section has the a2main.cpp which is what our professor built.</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