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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:08:29+00:00 2026-05-25T15:08:29+00:00

My application keeps crashing on me for whatever reason. I am new to vectors

  • 0

My application keeps crashing on me for whatever reason. I am new to vectors so there is more than likely something silly on my part.

#include <iostream>
#include <vector>    

using namespace std;

class Projectile
{
private:
    SDL_Surface *projectile;
    void load();

public:
    int count;

    vector< int > c;
    vector< vector< int > > p;

    int positionX;
    int positionY;

    Projectile();
    void newProjectile( int, int );
    void drawCurrentState( SDL_Surface* );
};

...
...

void Projectile::newProjectile( int x, int y )
{
    positionX = x;
    positionY = y;

    c.push_back( 10 );
    c.push_back( 10 );

    //p.push_back( c ); //trying to start off simple before i do multidimensional.
}

void Projectile::drawCurrentState( SDL_Surface* destination )
{   
    SDL_Rect offset;
    offset.x = c[0]; //will eventually me the multidimensional p vector
    offset.y = c[1]; //

    SDL_BlitSurface( projectile, NULL, destination, &offset );
}

what exactly am I doing wrong here? I push back two values ( will be the x and y ints after done testing ) however it seems to crash when it gets to the offset.x = c[0]; part of the script.

I thought for certain both c[0] and c[1] should be equal to 10. Any suggestions?

  • 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-25T15:08:30+00:00Added an answer on May 25, 2026 at 3:08 pm

    You’re right, both [0] and [1] should be 10.

    Just make sure you really call newProjectile() first, and make sure there are no other problems such as invalid destination pointer and so on.

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

Sidebar

Related Questions

My application keeps crashing when I type something in a EditText, but this does
i have written an application, but for some reason it keeps peaking at 100%.
Our flex (flare) application keeps timing out when rendering large datasets. Is there anyway
My application keeps crashing and i do not know what went wrong. I merely
In specific: Im doing some math operations, and the application keeps crashing because a
When I run my Ruby on Rails application locally, it keeps crashing on one
My application keeps running into Timeout Expired SqlExceptions. The thing is that this query
An application keeps track of hundreds of variables. Users are able to create conditions
My Connection to my test application keeps terminating in the same place without any
I'm trying to load values into a SQLite table on android. My application keeps

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.