Hello, this is my first post here. I'm playing around with Gtk+ and Xlib. I'm trying to get the X window ID of the active window, and then display that ID in a Gtk label. However, when I run it, it seg faults. I've narrowed it down to `XGetInputFocus`, but I'm stuck, because it seems like I'm supplying it with the parameter types it needs. All three parameters are `*Display`, `*Window` and `*int`, which is what I'm supplying it, according to https://tronche.com/gui/x/xlib/input/XGetInputFocus.html 1. What am I doing wrong? 2. Also, when I compile with `gcc -Wall `pkg-config --cflags gtk+-3.0` -o …

Member Avatar
Member Avatar
+0 forum 1

Hello. I need to set up some pipes for a homework assignment as part of a bigger project. The issue I'm having is that the array (args) I'm using to populate the pipe arguments keeps segfaulting and I don't know why. Everything has been malloced beforehand and the faults only occur at the mentioned places. Below, the relevant code: char** args; char** pipe1_args; int pipe1_args_size; char** pipe2_args; int pipe2_args_size; while (temp_std_command && array_size <= 255) //take args and break them up into an array { args[i] = malloc(sizeof(char)*255); strcpy(args[i], temp_std_command); temp_std_command = strtok(NULL, " "); i++; array_size++; } i++; array_size++; …

Member Avatar
Member Avatar
+0 forum 2

Hey I have an code in Qt that is an QPushButton is hidden at start of the cpp but later i want to get it appear when the file is open and an line is readed but the problem i get an segmentation fault. Can be because the setHidden(true) in an another function the problem? Here goes the codes it's worth more than simple words FenPrincipale.cpp #include <iostream> #include <fstream> #include <string> #include <QApplication> #include <QLabel> #include <QComboBox> #include <QMessageBox> #include <QLabel> #include <Qt> #include "FenPrincipale.h" #include "Personnage.h" #include "Ennemis.h" #include "Barbare.h" #include "Magicien.h" #include "LevelUp.h" #include "UtiliserObjet.h" #include "SystemeBataille.h" …

Member Avatar
+0 forum 0

Hey guys, I'm loading from a dictionary with a variable called "buffer". I'm trying to copy "buffer" in to another array word for word. For some reason, when I try using `strncpy()`, it yields a segfault. Here is my code (assuming "LETTERS" is 29: bool load(string filename) { // open dictionary FILE* file = fopen(filename, "r"); if (file == NULL) return false; // load words from dictionary char buffer[LETTERS + 2]; int size = 0; while (fgets(buffer, LETTERS + 2, file)) { // overwrite \n with \0 buffer[strlen(buffer) - 1] = '\0'; strncpy(arrayList[size], buffer, LETTERS + 2); size++; } return …

Member Avatar
Member Avatar
+0 forum 3

Hey guys, I'm working with `strchr` and, for some reason, am getting a segfault. My program takes a string, iterates through the characters of that string, and adds a score to the "game" based on what letter the current character is. That sounds complicated, but my code will explain it: // initialize alphabet and corresponding scores as arrays char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int scores[] = {1, 4, 4, 2, 1, 4, 3, 3, 1, 10, 5, 2, 4, 2, 1, 4, 10, 1, 1, 1, 2, 5, 4, 8, 3, 10}; char word[] = "hello"; // iterate through word for …

Member Avatar
Member Avatar
+0 forum 4

Hello all! I have used this forum many times in the past to solve a variety of programming related problems, but am truly stumped on a segfault within a binary search tree. I have isolated the segfault to a fscanf statement that look legitamate to me. The following code blocks are the function that contains the fscanf statement: int fscan_unit(FILE *filep, object_t *object){ int status; /************************** SEGFAULT **************************/ status = fscanf(filep, "%d%d%d%s", &object->id, &object->section, &object->credits, object->course ); /************************** SEGFAULT **************************/ if(status == 4){ status = 1; } else if(status != EOF){ status = 0; } return status; } and the …

Member Avatar
Member Avatar
+0 forum 2

I don't really have an explanation and whoever thought that this new posting format was the way to go... idk what to say. I really don't like it. I can only post so much lines of code before something happens to the window and I can't scroll all the way down. Anyway, its segfaulting when I assign a value to a reference. Not sure why that's happening. repost from cplusplus.com. Just trying to get some answers don't mean to spam. GDB: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000030 [Switching to process 27451] 0x0000000100007413 in …

Member Avatar
Member Avatar
+0 forum 3

I'm writing a program to convert Decimal numbers to binary, hexadecimal, and BCD as a refresher before i start getting code assignments in school. I'm almost done, but i have a seg_fault (compiler says decToHex function) in 1 function and i am hoping for some feedback on the others. I'll break it up a little so it's not 1 giant block of code and attach the .CPP [B]Class Definition[/B] [CODE] class ConvertDecimal { public: ConvertDecimal(); //void print(); private: int MAX_SIZE; void Convert (); string decToBinary (int decimal); string decToHex (int decimal); string decToBCD (int decimal); char hex(int num); string BCD(char …

Member Avatar
Member Avatar
+0 forum 7

[I]To make it easier to read, only the relevant code is below, and due to circumstances beyond my control im stuck using Xcode for the next week or so (hate this debugger).[/I] I need help fixing a seg_fault in my current program. It occurs the last time "buildPaths" is called. I feel like im going outside of the "thePaths" vector, but the fixes I've tried did nothing. Please tell me either A) A solution, where the problem was, how to avoid it, how to go about fixing it B) Where the problem is, how to go about fixing it, how …

Member Avatar
Member Avatar
+0 forum 3

Please help me fix my code.. It works in CodeBlocks but when I try in Linux, it says it has an error - SEGMENTATION FAULT (core dumped) :( This program converts between bases of a number. After it converts a number it should go back to start to get input again.. [CODE]#include<stdio.h> #include<stdlib.h> typedef char string[64]; //Converting the character to integer int charToInt(char ch){ if(ch>=48 && ch<=57) return (int)(ch-48); if(ch>=65 && ch<=90) return (int)(ch-55); } //Converting the integer to character char intToChar(int x){ if(x>=0 && x<=9) return (char)(x+48); if(x>=10 && x<=35) return (char)(x+55); } int main(){ int currentBase = 0, …

Member Avatar
Member Avatar
+0 forum 3

so i have this program written and i am getting a seg fault and the stack said in operator<<. I have no idea how to fix this...It is due in thirty minutes if someone can please help me asap. Here is where i think the problem lies: [CODE]#include <iostream> #include <fstream> #include <cstdlib> #include <iomanip> #include "listT.h" using namespace std; struct purchase { string description; float cost; //Overloading equality(==) operator bool operator== (purchase& otherPurchase) { if(description == otherPurchase.description) { if(cost == otherPurchase.cost) { return true; } else return false; } else return false; } //Less than(<) operator definition bool operator< …

Member Avatar
Member Avatar
+0 forum 1

Hi, I'm getting segmentation fault errors when I use quicksort with ~350 000+ numbers. This is the quick sort algorithm I'm using: [CODE]void swap(int* v, int i, int j) { int tmp = v[i]; v[i] = v[j]; v[j] = tmp; } int partition(int *v, int s, int e) { int p = v[e], i = s - 1; for (int j = s; j < e; j++) { if (v[j] <= p) { i++; swap(v, i, j); } } i++; swap(v, i, e); return i; } void quicksort(int* v, int s, int e) { if (s < e) { int …

Member Avatar
Member Avatar
+0 forum 6

I am currently creating a queue ADT for one of my classes in college. We are using a linux ssh server for compiling our programs, but i am writing the code in windows. When i compile i get no errors, but when i run it goes fine until it hits the copy constructor Queue300 two(one); at which point i get a segfault and the program ends. im sorry if its a little cryptic to read but my instructor believes that typedef is the most amazing thing since sliced bread. my code is as follows: [B][U]header[/U][/B] [CODE]#ifndef OBERLOHA3_H #define OBERLOHA3_H typedef …

Member Avatar
+0 forum 0

Hi all, I am currently working with some c++ code on an ARM processor. The issue i am having is that when my application hits a segfault i am unable to get any information as to what caused it. My dev machine is ubuntu 10.04 LTS and i am using eclipse as my IDE (just for how it looks, the compliation is a makefile using autoconf). Im using the GCC ARM cross compiler from openembedded and the cross compiled GDB also from openembedded. Output of compiler version below. [quote] arm-angstrom-linux-gnueabi-g++ -v Using built-in specs. Target: arm-angstrom-linux-gnueabi Configured with: /home/robert/openembedded/angstrom-setup-scripts/build/tmp-angstrom_2008_1/work/armv7a-angstrom-linux-gnueabi/gcc-cross-4.3.3-r23.2/gcc-4.3.3/configure --build=i686-linux …

Member Avatar
Member Avatar
+0 forum 2

The End.