Category "c"

How to detect if a tun/tap device already exists

I want to create a tun device with the code, so before creating it I want to check if the tun device already exists Right now I'm doing this by determining if t

Can I use #undef and #define mid code to change something in another function?

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <ctype.h> #define TYPE char typedef struct n

Command line arguments

How would i go about coding (in C) a program that accepts one command line argument, (that includes the program name and the port number that will be used for t

C++/C Importing Third Party Library to CMake

Hi I was wondering if anyone here could help me identify what I'm doing wrong while trying to add a library to my CMake project: So originally I built the libra

Matlab new C++ MEX function runnign speed vs C Mex interfaces

Recently I am working on boosting Matlab project performances. As you may know, Matlab 2017 introduced a new C++ Mex function to avoid unnecessary data copies,

Strtok returning the same and incorrect string infinitly

So I am studying system calls in c and I am doing this exercise that I have to make a simple program that search for a file in the PATH (kinda similar to which

C: Rounding floats

Could you please explain this code: printf("Value1: %0.1f \n", (float)124/100); // = 1.2 printf("Value1: %0.1f \n", (float)125/100); // = 1.2 printf("Valu

Pause or Getchar with push button

I'm new to programming and I'm trying to put a pause in my code before my while(1) loop in in my main(). The pause will be broken after the state of a push butt

Is there a maximum number of continuous pages per process in Linux? If so, how to set it to unlimited?

The following code will generate errno 12 cannot allocate memory #include <sys/mman.h> #include <stdio.h> #include <stdlib.h> #include <fcn

Simple expression calculator in C - stacks' application

Write a program that solves arithmetic expressions, passed as a string, printing its value. Use two stacks, one for operands and one for operators. Consider on

How to make a C console app wait before exiting?

It seems that I can't find any solution to this problem, so I'm asking you. C doesn't support iostream and Console.Readkey unless i did something wrong, so plea

no speedup using openmp simd and different result between icc and gcc [duplicate]

I am new to Openmp and now trying to use Openmp + SIMD intrinsics to speedup my program, but the result is far from expectation. /* program:s

bilinear interpolation with DSP CMSIS library - passing 2D array

I am struggling to obtain the correct results for the function with CMSIS DSP bilinear_interp. I've first tried a simple linear interpolation: float test_tabl

how to read data from a file in this exercise?

I have to do this exercise: short explanation: read a file, and store informations in a struct pointed to by a pointer. long explanation: I have a struct "pe

Code that compiles with gcc but not with g++

I am writing a program in c, but i need to use a c++ library to work with an ADC's. In my code I have a library that I wrote called scheduler, this library comp

How to debug a C application that is called by another process and ends very quickly in Visual Studio?

I can't attach to the C application process because it ends only milliseconds after being called. And the caller is an exe that I don't have the source code.

How do you assign a multidimensional array of pointers to a multidimensional array of values in C?

I'm working on a Sudoku Solver, and I have to evaluate values in RealPuzzle (without changing them), and then decide whether or not the desired number can go so

Migrate a "zmq_send" command to Python

I have a c function that publish data to a c++ subscriber, now I want to migrate this c function to Python: void setup_msg_publish() { int r; zmqcontext

SIMD - "sorting" zeros in a vector [duplicate]

Please tell me on this issue, for example, I have a vector __m128i - filled as an int, that is, each value takes 4 bytes: __m128i my_m128i = _

How to use software prefetch systematically?

After reading the accepted answer in When should we use prefetch? and examples from Prefetching Examples?, I still have a lot of issues with understanding when