Category "c"

Can extern make a function variable a global variable?

As I understood extern makes a variable --> global variable, so it means we can also make variable of another function a global variable? #include <stdio.

Writing matrix of ints to .txt

I'm trying to write a 479x639 matrix of ints to a .txt file. Preferably each line will include one entry followed by a ,, so that I can input the data on MATLAB

Weird characters appearing at the beginning of my code

I've created a code which displays integers till a given value with numbers (up to the maximum of the two digit range), and shows the tens as text. I have notic

How to read from a file and parse it

I have a file .txt containing some values formatted like this: 0,30,25,10 Now, I open up the file and store it into an array char imposta_tratt[300]; FILE *f

Can ssh accept an encrypted password?

I'm designing an app recently. For some reasons I can not use the ssh-key to connect to the remote server, so I wonder whether I could just pass an encrypted pa

simulating '<' operator in a c programme

I am recreating a complete shell. For that I must simulate <. To do this, I have to use the function dup2(). I made this but it didn't work and I donc't unde

How to fix and understand this Segmentation Fault (core dump) error? I cannot comprehend it whatsoever

I am tasked with creating a C code that does what page-replacement algorithms do. The code is barely 200 lines, so I will try to send some portions and hopefull

Platformio compilation error in bison file

I'm using bison with flex combined with Arduino framework in Platformio. Compiling .y and .l files goes without a problem, but when I'm trying to make a Build i

forked process doesn't exit when parent invoke waitpid()

In this program 2 children process are forked, then one send string to another through pipe. When communication finished, the parent get stuck in waiting the ex

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