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

The Archive Base Latest Questions

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

I keep getting a segmentation fault with this Bingo Board I’m trying to create

  • 0

I keep getting a segmentation fault with this Bingo Board I’m trying to create in C++. Valgrind didn’t tell me much more than this:

==2734== Memcheck, a memory error detector
==2734== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==2734== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==2734== Command: ./Bingo
==2734== 
==2734== Invalid read of size 1
==2734==    at 0x5D0A436: vfprintf (vfprintf.c:1620)
==2734==    by 0x5DBF8ED: __printf_chk (printf_chk.c:37)
==2734==    by 0x400FC0: generate(int, int) (in /home/holland/Code/cpp/Bingo-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/Bingo)
==2734==    by 0x400B69: main (in /home/holland/Code/cpp/Bingo-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/Bingo)
==2734==  Address 0x62 is not stack'd, malloc'd or (recently) free'd
==2734== 
==2734== 
==2734== Process terminating with default action of signal 11 (SIGSEGV)
==2734==  Access not within mapped region at address 0x62
==2734==    at 0x5D0A436: vfprintf (vfprintf.c:1620)
==2734==    by 0x5DBF8ED: __printf_chk (printf_chk.c:37)
==2734==    by 0x400FC0: generate(int, int) (in /home/holland/Code/cpp/Bingo-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/Bingo)
==2734==    by 0x400B69: main (in /home/holland/Code/cpp/Bingo-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/Bingo)
==2734==  If you believe this happened as a result of a stack
==2734==  overflow in your program's main thread (unlikely but
==2734==  possible), you can try to increase the size of the
==2734==  main thread stack using the --main-stacksize= flag.
==2734==  The main thread stack size used in this run was 8388608.
 ==2734== 
==2734== HEAP SUMMARY:
==2734==     in use at exit: 86,091 bytes in 276 blocks
==2734==   total heap usage: 2,819 allocs, 2,543 frees, 246,187 bytes allocated
==2734== 
==2734== LEAK SUMMARY:
==2734==    definitely lost: 0 bytes in 0 blocks
==2734==    indirectly lost: 0 bytes in 0 blocks
==2734==      possibly lost: 0 bytes in 0 blocks
==2734==    still reachable: 86,091 bytes in 276 blocks
==2734==         suppressed: 0 bytes in 0 blocks
==2734== Rerun with --leak-check=full to see details of leaked memory
==2734== 
==2734== For counts of detected and suppressed errors, rerun with: -v
==2734== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)

Here’s my code:

#include <vector>
#include <iostream>
#include <algorithm>
#include "board.h"

#define MIN 0
#define MAX 15

using std::vector;
using std::random_shuffle;
using std::cout;
using std::endl;

void generate(int numRows, int numColumns) {

    std::vector<int> b;
    std::vector<int> i;
    std::vector<int> n;
    std::vector<int> g;
    std::vector<int> o;

    char * bingo = "bingo";

    for(int index = MIN; index <= 15; index++)
    {
        b.push_back(index);
        i.push_back(index + 15);
        n.push_back(index + 30);
        g.push_back(index + 45);
        o.push_back(index + 60);
    }

    std::random_shuffle(b.begin(), b.end());
    std::random_shuffle(i.begin(), i.end());
    std::random_shuffle(n.begin(), n.end());
    std::random_shuffle(g.begin(), g.end());
    std::random_shuffle(o.begin(), o.end());

    for (int i = 0; i <= 5; i++)
    {
        printf(" %s ", bingo[i]);
    }

    for (int j = 0; j <= 15; j++)
    {
        printf(" %d %d %d %d %d \n", b.back(), i.back(), n.back(), g.back(), o.back());
        //b.pop_back();
        //i.pop_back();
        //n.pop_back();
        //g.pop_back();
        //o.pop_back();
    }

    delete bingo;

}
  • 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-25T22:59:47+00:00Added an answer on May 25, 2026 at 10:59 pm

    The problem is with:

    delete bingo;
    

    where bingo is not pointing to memory obtained from use of new but is pointing to a string literal.

    Also the format specifier or the argument to printf is incorrect:

    printf(" %s ", bingo[i]);
    

    %s expects argument to be a char * but your argument type is integer. Either change the format specifier to say %c or %d OR change the argument.

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

Sidebar

Related Questions

I can't get to know why do I keep getting this segmentation fault in
Im working on this bit of code and I keep getting a segmentation fault.
I'm keep getting a segmentation fault from where I create thread and declare some
Keep getting this error after inserting a subdatasheet into a query and trying to
I keep getting this error when trying to delete a record from my table.
I keep getting this error mesage when trying to add a breakpoint in gdb.
I keep getting tasks that are above my skill level. How can I address this without coming accross as grossly incompetent?
I keep getting this NPE in my application and I can't seem to get
I keep getting this : DeprecationWarning: integer argument expected, got float How do I
I am trying to do something really basic on C but I keep getting

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.