Segmentation Fault Issue in Matrix GDB Project

I’m working on a GDB project for class an I’m finding issues with a segfault portion in a piece of code that reads a file and creates a matrix with the input. GDB brings me to the "printf("%.2d\t", mat[row][col]);" in printMatrix() but I can’t seem to grasp what exactly goes wrong. int main(int argc, char*… Read More Segmentation Fault Issue in Matrix GDB Project

C gives segmentation fault and a warning for two different lines. What can I do to solve this issue?

I’m still a beginner in C, but as training I would like to create a Password Manager(a very bad on though). First a .txt file is created, and then the user is given an option of what they would like to do next. Using strcmp I make the program decide what function to execute next.… Read More C gives segmentation fault and a warning for two different lines. What can I do to solve this issue?

C++ returning an rvalue doesn't work and segfault

I have a function what creates a vector, does somthing with it and then return it as an rvalue using std::move. When I am assigning it to a variable, I’m expecting to call std::vector‘s move constructor std::vector::vector(vector&&). But I’m getting a segmentation fault. Here’s my code: #include <iostream> #include <vector> std::vector<int>&& getVector(int start) { auto… Read More C++ returning an rvalue doesn't work and segfault

std::pair returned by std::transform resulting in segfault

I’m trying to transform a vector of strings to a vector of pairs of strings, and I was getting segfault. I’ve tried to narrow it down to a simple test case (below), and I’m sure it’s likely to do with the memory allocation: #include <string> #include <vector> #include <utility> std::pair<std::string, std::string> newP( const std::string& foo)… Read More std::pair returned by std::transform resulting in segfault

Every few attempts to run my build, I get a segmentation fault. I dont understand why

So i’m getting a Segmentation fault: 11 error and I know which block is causing it, but i’m trying to understand why. std::vector<Entity> grassEntities; for (int i = 0; i < 40; i++) { grassEntities.push_back(Entity(i * 32, 592, grassTexture)); } std::vector<Entity> dirtEntities; for (int i = 0; i < 4; i++) { for (int j… Read More Every few attempts to run my build, I get a segmentation fault. I dont understand why