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 6949133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:54:52+00:00 2026-05-27T13:54:52+00:00

I’ve been debugging this error for the last 2 hours, and knowing myself I

  • 0

I’ve been debugging this error for the last 2 hours, and knowing myself I won’t be able to sleep if I don’t ask for help before I go to bed. I’m writing a model loader for my game, and just for now I’m using a pretty flimsy method to split strings. However, it works on nearly identical lines, then randomly doesn’t. I’m using string.substr(), and I believe the error means its trying to start at a location that doesn’t exist in the string. The call stack says its happening on this line:

v1 = v1.substr(s.find(",")+1);

and by using a breakpoint that prints a message, it says

Vertex 1 is using “1,1” and the entire string is “173,1,1 175,1,1
174,1,1”

where Vertex 1 is the value of v1, and string is the value of s.

This is the entire function:

FaceData data;
s = s.substr(5); //remove "FACE "
string v1, v2, v3;

//vertex 1
v1 = s.substr(0, s.find(" "));

data.vertexIndexes[0] = atoi(v1.substr(0, s.find(",")).c_str());
v1 = v1.substr(s.find(",")+1);
data.textureIndexes[0] = atoi(v1.substr(0, s.find(",")).c_str());
v1 = v1.substr(s.find(",")+1);
data.normalIndexes[0] = atoi(v1.c_str());

//vertex 2
s = s.substr(s.find(" ")+1);
v2 = s.substr(0, s.find(" "));

data.vertexIndexes[1] = atoi(v2.substr(0, s.find(",")).c_str());
v2 = v2.substr(s.find(",")+1);
data.textureIndexes[1] = atoi(v2.substr(0, s.find(",")).c_str());
v2 = v2.substr(s.find(",")+1);
data.normalIndexes[1] = atoi(v2.c_str());

//vertex 3
s = s.substr(s.find(" ")+1);
v3 = s;

data.vertexIndexes[2] = atoi(v3.substr(0, s.find(",")).c_str());
v3 = v3.substr(s.find(",")+1);
data.textureIndexes[2] = atoi(v3.substr(0, s.find(",")).c_str());
v3 = v3.substr(s.find(",")+1);
data.normalIndexes[2] = atoi(v3.c_str());

return data;

the std::string ‘s’ being passed to the function always looks like this:
“FACE X,X,X X,X,X X,X,X”
where x is a number.

This is the only way I could find to split a string…

Now, I don’t understand why it is getting this error here… It seems like it’s almost just happening randomly. I can’t understand why it won’t work with

173,1,1 175,1,1 174,1,1

but it will work with

175,2,2 176,2,2 175,2,2

  • 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-27T13:54:53+00:00Added an answer on May 27, 2026 at 1:54 pm

    I’m not sure I’m interpreting your question correctly, but given the information you provided, this seems to be what you’re doing:

    #include <string>
    #include <iostream>
    
    int main() {
        std::string v1 = "1,1";
        std::string s = "173,1,1 175,1,1 174,1,1";
    
        try {
            v1 = v1.substr(s.find(",")+1);
        }
        catch (const std::out_of_range& e) {
            std::cout << "out_of_range: " << e.what() << std::endl;
            return 1;
        }
        return 0;
    }
    

    In that case, s.find(",") will return 3 (the first , in s is at position 3), however since v1 only has three characters the only valid indexes are between [0,2]. Passing in 3, or with the +1 4 would be out of range for v1.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.