October 22, 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++

Warning: Iteration 1 Invokes Undefined Behavior

I’m not seeing the issue. typedef struct GeneralSensorParams_ { uint8_t threshold; uint8_t negativeThreshold; uint8_t baselineThreshold; } GeneralSensorParams; typedef _ALIGNED_(64) struct GeneralNVParams_ { uint32_t checksumOffset; GeneralSystemParams system; PerSensorBitFields bitfields[10]; GeneralSensorParams sensor[1]; uint8_t checksum; } GeneralNVParams; GeneralNVParams const* G_pGeneralNVParams = NULL; int main (void) { for (uint8_t i = 0; i < 1; i++) { if (tempThreshold[i]

Read More
C++

malloc & free in C with multidimensional arrays in C; Whats wrong with the code

I am a beginner and i am working on a code where the multidim arrays are allocated with the malloc, malloc variant. I have to add an Array with a higher dimension (3D instead of 2D). I discovered a strange behavior and i would be thankful for an explanation. I know this is not really

Read More
C++

Matrix multiplication code runs without error but gives no output

This code for matrix multiplication asks the user for input and everything but doesn’t give any output. Can anyone please help? #include <stdio.h> int i, j, k, l = 0; int r1, r2, c1, c2; void matMul(int m1[r1][c1], int m2[r2][c2], int res[r1][c2]){ for (int a = 0; a < r1; a++){ for (int b =

Read More
C++

A Deep Dive into the Producer-Consumer Problem in C

Producer-Consumer Problem (Bounded Buffer Problem) Overview The Producer-Consumer problem is a classic synchronization challenge in concurrent programming, where two threads—the producer and the consumer—interact with a shared, bounded buffer. This problem requires careful management to ensure that: The producer must not insert data when the buffer is full. The consumer must not pick or remove

Read More
C++

Unable to cross compile simple C program using clang and lld

$ cat hello.c int main () { return 0; } $ clang -fuse-ld=lld -target ppc64le hello.c -o hello.o ld.lld: error: /tmp/hello-37cf01.o is incompatible with elf64-x86-64 collect2: error: ld returned 1 exit status clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation) Simple compiling and "not" linking step works

Read More
C++

fallocate not defined in QEMU 7.2.14 trying to compile on windows using mingw

Trying to compile QEMU 7.2.14 so I can use HAXM virtualizer to accelerate it (not using hyperv) and I’m getting an error saying that the fallocate function is not found in file qemu/softmmu/physmem.c line 3600, I have already tried looking for a fix but I can’t find one & this function seems to be linux

Read More
C++

cc1plus.exe: fatal error: code.cpp: No such file or directory compilation terminated

when i run the c++ code in visual studio. I am getting this issue , please hepl me to fix this problem. it not show output. i don’t know. what’s the problem. i have attached screen shot. kindly help me to solve this problem. You need to sign in to view this answers

Read More
C++

click allow cookies popup on firefox selenium c#

I want to click on allow option which is coming out from a pop up of a website ,I want to do on firefox to allow cookies: i try this code but not work : FirefoxDriverService cService = FirefoxDriverService.CreateDefaultService(".", "geckodriver.exe"); cService.HideCommandPromptWindow = true; FirefoxOptions options = new FirefoxOptions(); options.AddArgument("ignore-certificate-errors"); options.AddArgument("--user-data-dir=" + FolderPathToStoreSession); options.AddArgument("--disable-notifications"); options.AddArguments("Firefox.switches", "--disable-extensions");

Read More
C++

Visual studio code is not giving me output in C,even when my code is correct

I installed Visual studio and also installed all the extensions which were necessary for C.I write my code correct but everytime there is some specific error.enter image description here.I tried deleting files and folders and again creating folders on different locations,but it’s not working.I even asked chatGPT but its saying that your code is correct.Please

Read More
C++

Casting in C – confused

I have a tiny little code snipplet here: #include <stdio.h> #include <math.h> void main(void) { int clouds=15; double Zenith_rad=1.1827, Normal_direct=774.6839, A=0, B=0, C=0; A = Normal_direct * cos(Zenith_rad); B = A * ( 1 - ( clouds / 100)) ; C = A * ( 1 - ( 0.15)) ; printf("A: %f\n" ,A); printf("B: %f\n"

Read More