c#

PyOpenCL: how to create a local memory buffer?

Probably extremely simple question here, but I’ve been searching for it for hours with nothing to show for. I have this piece of code, I’d like to have a 256-bit (8 uint32) bitstring_gpu as a localmemory pointer in the device: def Get_Bitstring_GPU_Buffer(ctx, bitstring): bitstring_gpu = cl.Buffer(ctx, mem_flags.READ_ONLY | mem_flags.COPY_HOST_PTR, hostbuf=bitstring) return bitstring_gpu This is later used on a kernel call:…
Read more

getting numbers after decimal point in float value as exact as input in c++ or c

I wanted to print the output of the float or double value as exact as my input. so for each number different significant value as input. #include<stdlib.h> #include<stdio.h> int main() { float e=4.887; // 3 digits after decimal and so on double f=49.9759349; // want exactly same 7 digit in this case without specifying 7lf printf(%f %lf”,a,b); return 0; }…
Read more

Variable scope behavior c language

Code snippet: void function(void) { while(1) { int i = 0; i += 1; if(i == 500) break; } } The variable i is stored in stack every time when restart the loop ? What is the memory structure when running this code ? What is the behavior of this variable ? It is a bad or good practice do…
Read more

Assembly 32bit – compare char

I have a C program that calls a function written in 32bit assembly which check if the input is a character or a number, then return 1 else return 0. I’ve done something wrong because the comparison return to me always the same result. Here the C code: #include <stdio.h> #include <stdlib.h> int aisalnum(int *ascii); //char atoupper(char *a); //char astripnoalnum(char…
Read more

Dereferencing pointer to incomplete type in stack

I have checked the other questions with similar problems, but none of the solutions worked for my case. The problem in hand is, I am trying to create a stack with dynamic memory, using this struct: struct stekas{ int content; struct stekas *link; } *top = NULL; However, I’m running into trouble in a few of my functions: Specifically, “Dereferencing…
Read more

Read string and various integers in same line in C

so I have a string called buffer which has the following stored: Rb [7, 0] 64 Using sscanf, I’d like to read Rb and store it in a string called name, read 7 and store it in a int variable called posx, read 0 and store it in a int variable called posy, and read 64 and store it in…
Read more