October 21, 2024
Chicago 12, Melborne City, USA

C++

C++ is a general-purpose programming language. Use this tag for questions about/utilizing C++. Do not also tag questions with [c] unless

C++

Dev-C++ terminal window closes right away after I run my code

Every time I run my code, the terminal window closes right away. I have already tried multiple ways to fix it but none of them have worked yet. I aded "getc();" before "return" and it doesn’t work anyway. I’m unsure of what to do next. This is my code: #include <stdio.h> int main() { printf("Hello,

Read More
C++

Publish GTK+ Application with msys2 and mingw64

I want to publish my GTK+ application with mingw64. But although I copied the gdkpixbuf loaders in right place, the application can’t find gdkpixbuf loaders and My application look’s worse. How can I fix this problem? I am copied gdkpixbuf loaders in lib\gdk-pixbuf-2.0\2.10.0\loaders path but It wasn’t working You need to sign in to view

Read More
C++

incrementing LATEX fraction recursively in C

i am trying to write a program that gets input step and prints the following in LATEX format .(https://i.sstatic.net/cF4Kc9gY.png)](https://i.sstatic.net/cF4Kc9gY.png) for example for step = 3 , the output is 1+\frac{2+\frac{4}{5}}{3+\frac{6}{7}} this is the code i have write now but i get *** stack smashing detected ***: terminated error for inputs more than 6. any idea

Read More
C++

method for Calculating / Retrieving CPU Clockspeed in C?

For an assignment, I’ve been trying to work on a project to inspect and retrieve system information on Linux either in pure C, or inline ASM. A bit of a problem I’m having now is actually retrieving the clockspeed. I initially attempted to just read from __cpuid: __cpuid(0x80000002 + i, eax, ebx, ecx, edx); I

Read More
C++

Trouble with CS50 filter-less (blur) code works on an image but only passes 1/5 checks

I’ve been stuck with the same error messages and wondering if someone can help point out what I’m missing. Currently the code does blur an image but the only check the code passes is regarding the corner pixels, by that logic i am finding it hard to understand why the edge and middle pixels would

Read More
C++

Old GCC 4.4.7 wasn't initializing randomly

I was compiling C legacy projects using: gcc (GCC) 4.4.7 20120313 On a RedHat6 environment, pretty old. Now I’m using: gcc (GCC) 8.5.0 20210514 On a RedHat8 environment, which is better. Flags were: -Wl,-s -m32 -o $@ Wuninitialized -Winit-self -Warray-bounds -ftree-vrp Only diff is I needed to add ""lm", now: -Wl,-s -m32 -o $@ Wuninitialized

Read More
C++

Error Compiling Binutils for i386-elf on macOS

I’m trying to cross-compile binutils for i386-elf on macOS (Sequoia 15.0.1, arm64) but encounter an error when running make. Here are the steps I followed: Installed required dependencies: brew install gmp mpfr libmpc texinfo Downloaded and extracted binutils 2.41: mkdir -p ~/src cd ~/src wget https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.gz tar -xzf binutils-2.41.tar.gz Created a build directory: mkdir build-binutils

Read More
C++

What replaces AES_set_decrypt_key and AES_unwrap_key in OpenSSL 3?

The AES_set_decrypt_key and AES_unwrap_key functions are deprecated in OpenSSL 3. I’m maintaining a function which uses them that I’d like to update to use non-deprecated functions: std::unique_ptr<uint8_t[]> rfc3394_key_unwrap(const uint8_t* key, size_t key_len, const void *input, size_t input_len, const void *iv) noexcept { AES_KEY aes_key; AES_set_decrypt_key(key, key_len * 8, &aes_key); const int output_len = input_len -

Read More
C++

Circular definition with struct and function in C

I have these two simplified files: lexer.h #ifndef LEXER_H #define LEXER_H #include "expand_array.h" // Union to store token value typedef union { //Problem is here bcs of circular definition //---------------------------------------- DynamicCharArray arr; // For identifiers, strings, ... int intValue; // For integer literals float floatValue; // For floating-point literals } TokenValue; // Structure representing a

Read More
C++

How does printf() works as a safe cancel point? What is it depends on?

I have this little program that is supposed to create a thread and cancel it. #include <stdlib.h> #include <stdio.h> #include <pthread.h> #include <unistd.h> void *thread_function(void *arg) { while(1) { printf("hello \n"); //sleep(1); } return NULL; } int main() { pthread_t thread; if(pthread_create(&thread, NULL, thread_function, NULL) != 0) { perror("Failed to create a thread"); return -1;

Read More