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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:07:27+00:00 2026-05-25T11:07:27+00:00

Hi guys i’m trying to debug this application in C++ using netbeans (running it

  • 0

Hi guys i’m trying to debug this application in C++ using netbeans (running it gives me run failed after closing it) it gives me a signal error at this point

*c = (char)any number;

where any number is an integer from 1-7

it tells me signal caught SIGSEGV ? with signal error ?

what is it

the code writes some stuff to a binary file it goes like this

void clean_up(Dot &myDot, Uint32 &bg) {
    SDL_FreeSurface(DotS);

    ofstream f(SAVE_FILE_PATH, ios::binary | ios::out);

    f.clear();

//    char *buffer;

//    buffer[0] = *(char*)(&myDot.get_location().x + 0);
//    buffer[1] = *(char*)(&myDot.get_location().x + 1);
//    buffer[2] = *(char*)(&myDot.get_location().x + 2);
//    buffer[3] = *(char*)(&myDot.get_location().x + 3);
//    buffer[4] = *(char*)(&myDot.get_location().y + 0);
//    buffer[5] = *(char*)(&myDot.get_location().y + 1);
//    buffer[6] = *(char*)(&myDot.get_location().y + 2);
//    buffer[7] = *(char*)(&myDot.get_location().y + 3);

    f.write((char*)&myDot.get_location().x, sizeof(myDot.get_location().x));

    f.write((char*)&myDot.get_location().y, sizeof(myDot.get_location().y));

    char *c;

    if (bg == C0)
        *c = (char)1;
    else if (bg == C1)
        *c = (char)2;
    else if (bg == C2)
        *c = (char)3;
    else if (bg == C3)
        *c = (char)4;
    else if (bg == C4)
        *c = (char)5;
    else if (bg == C5)
        *c = (char)6;
    else if (bg == C6)
        *c = (char)7;

    f.write(c, 1);

    f.close();

    SDL_Quit();
}

and please can someone tell me why the commented part gives me a signal too

  • 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-25T11:07:27+00:00Added an answer on May 25, 2026 at 11:07 am

    You haven’t allocated memory to c. It’s a pointer to some random location (or NULL, depending on how memory is being initialized). You then try to write to it.

    Does it really need to be a pointer? Could you just use char c;, and then c = (char)1; etc. You’d then want to change your fwrite call to f.write(&c, 1); (or use fputc).

    EDIT: The commented out part of your code looks like it has the same underlying problem. You haven’t allocated any memory for buffer. If the example is the most of it, you’re only ever having 8 items, then declare it as char buffer[8] instead of as a pointer.

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

Sidebar

Related Questions

Guys, this can't be for real I'm trying to make a .NET 2.0 executable
Guys, I Started playing with django-nonrel, and am trying to run my old django
Hello guys i have a problem streaming PDF files with php, i'm using this
Guys this code is returning false in a blank page after submit.What is the
Guys I have this peace of code I'm using phonegap with jqueryMobile to develop
Guys, can someone give me a brief run through of how to change the
Hi Guys could you please help me refactor this so that it is sensibly
Hi guys I wrote this code and i have two errors. Invalid rank specifier:
Hi Guys can you please help me with this error? What is it? Server
Guys, I have a CSS Layout that I am using that has a header,

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.