Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8108287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:03:52+00:00 2026-06-06T01:03:52+00:00

This is a group assignment and it’s become rather difficult to the point our

  • 0

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.

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).

int segment::match(const char word[]) {
    int i;
    cout << data[0];
    data[0] == "OOP";
    cout << data[0];
    for(i=0;i<NUM_MAX;i++) {
        cout << "word = " << &word[i] << " data[i] = " << data[i];
        if(strstr(&word[i],data[i])!= NULL)
        break;
    }
       return i==NUM_MAX ? 1 : i-1;

and from the main.cpp (provided to us as the assignment) this is the what we are trying to accomplish

Passed test 11…

Your match( ) return value ----> -1
Actual match( ) return value --> -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 ----> -1 
Actual match( ) return value --> 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!

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.

I guess what I’m asking is how do I make that function that it returns both -1 and 1 in the proper order?

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.

Any help is appreciated, thank you.

EDIT*
Here is the full code that we have
http://jsfiddle.net/h5aKN/

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:03:53+00:00Added an answer on June 6, 2026 at 1:03 am

    data[0] == "OOP"; is probably not what you want to do. The double = (==) tests for equality, so here you’re testing if the item at the first index of data (data[0]) and the character string "OOP" are equal.

    In the running of the test, you are cout’ing: word = OOP data[i] =, which means that word[i] is probably defined correctly, but data[i] is not. This goes back to the usage of the equivalence test above.

    If you set initialize data correctly, (correctly meaning allocating the memory correctly, I don’t know where data is instantiated), then the test would likely return -1, as it would get a non NULL pointer from the strstr() call (assuming that data is the correct type), i would be 0 on breaking, and the ternary operator would yield i-1, = -1.

    So fix the initialization / assignment of the data variable

    And if you’re not limited to c style strings (char arrays), I’d use the std::string type and its associated methods (see the c++ string reference if you haven’t already). Usually much nicer to work with

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently doing a group project for college in Java. The assignment is to produce
I have a table that looks like this Group Recipe Priority 0 A 400
How can ı add row numbers like this: GROUP 1 RowNumber ID Name Age
I have a crystal report that is like this: Group By Property.ID Group By
I installed java on my machine and I wanted to compile this group of
Consider this query to group a list of students by the 1st letter of
how can I split this barcode by group separator with Progress? I've tried chr(29)
I have a table like this: name code group john 12 smith 15 how
I have a table like this one: id group value 1 GROUP A 0.641028
I'm having an issue in my mongo group query: (this is PHP code) $conditions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.