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

  • SEARCH
  • Home
  • 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 6594107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:46:04+00:00 2026-05-25T17:46:04+00:00

I have 2 strings: in , which contains a link originally entered by the

  • 0

I have 2 strings: in, which contains a link originally entered by the user (assume it to be “http://google.com/test”), and found, which has already been found by an extraneous part of this program.

The goal of this function is to compare the section of string between http:// and /test, ie: “google.com”

The problem I’m encountering is that the loop is not adding to the compare string, thus the later attempt to compare the 2 strings in the program at runtime.

bool isLinkExternal(string in, string found)
{
    string compare = "";
    bool isExternal = false;

    //Get domain of original link
    for (int i = 6; in[i] != '/'; i++)
    {
        compare += in[i];
    }

    system("pause");

    //Compare domains of original and found links
    if (found.compare(7,compare.length(),compare) != 0)
        isExternal = true;

    return isExternal;
}

The error:

An unhandled exception of type
‘System.Runtime.InteropServices.SEHException’ occurred in
ParseLinks.exe

The line of code it points to:

if (found.compare(7,compare.length(),compare) == 0)

Fixed code (working):

bool isLinkExternal(string in, string found)
{
    const int len = found.length();
    int slashcount = 0;
    string comp;

    //Parse found link
    for (int i = 0; i != len; i++)
    {
        //Increment when slash found
        if (found[i] == '/')
        {
            slashcount++;
        }

        if (slashcount < 3)
        {
            comp += found[i];
        }
    }

    //Compare domains of original and found links
    if (in.compare(0,comp.length(),comp) == 0)
        return false;
    else
        return true;
}
  • 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-05-25T17:46:05+00:00Added an answer on May 25, 2026 at 5:46 pm
    (int i = 6; in[i] != '/'; i++)
    {
        compare += in[i];
    }
    

    Did you mean this?

    for (int i = 6; in[i] != '/'; i++)
    {
        compare += in[i];
    }
    

    At present, your string does not have seven characters in it, so your compare is invalid. In fact, you will need to add some bounds checking there in any case.

    Also, the exception text implies that you’re actually writing C++/CLI, not C++. Am I right?

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

Sidebar

Related Questions

I have textview which contains urls like www.google.com . for this textview a have
I have a client who is wanting to create a link which contains product
I have a link which contains several images. Upon hovering an interval is set
I have uploaded my code to pastebin, this is the link: http://pastebin.com/wBu9PP2x When i
I have certain strings which contain special characters so they can not be shared
I have a String which contains XML nodes within it, and am seeking to
I have a string which contains binary data ( non-text data ). How do
I have a string which contains only numbers. Now I want to remove all
I have a number of strings which contain words which are bunched together and
I have to work with strings which may contain Lat/Long data, like this: $query

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.