I’m using neovim in arch linux with the gcc C compiler, this is what I use in my .vimrc to compile and run map <F5> :w <CR> :!gcc % -o %< && ./%< <CR> The issue is that my code will run fine but any scanf() functions won’t prompt an input and will be ignored as the program will runs.
Tag: c++
C socket programming errors
It’s been an hour since I started looking for THE error. I just started C sockets. The program exits with code -1 after printing “Error 1 connection error”. The server in online, it’s a netcat server. Where did I messed up ? Answer Due to operator precedence, the expression is actually equal to That is, you assign the result of
Why open() has no ‘fd’ return in linux 1.0?
Since there is no return of ‘fd’, how does it read/write later for? ex: Answer open returns a value in there. The cast-to-void is used to signal the compiler that the return value is being deliberately ignored. The init function is the one where the current thread is prepared to execute the init program in user-space. init will expect the
How does pthread_cond_wait (conditon variable) unblock all threads only once, not multiple times?
I have successfully implemented a producer thread and 2 worker threads or consumer threads. The producer thread broadcasts condition using pthread_cond_broadcast. And the worker threads are blocked by pthread_cond_wait. The code looks something likes this: Thread 1 (Producer Thread): Thread 2 (Worker/Consumer Thread): Thread 3 (Worker/Consumer Thread): My question is why does Thread 2 or Thread 3 does not re-execute
Dynamic expansion of the Linux stack
I’ve noticed the Linux stack starts small and expands with page faults caused by recursion/pushes/vlas up to size getrlimit(RLIMIT_STACK,…), give or take (defaults to 8MiB on my system). Curiously though, if I cause page faults by addressing bytes directly, within the limit, Linux will just regularly segfault without expanding the page mapping (no segfault though, if I do it after
Decrypt and mount an eCryptFS encrypted directory using an external C++ script in Linux
I want to decrypt and mount the default eCryptfs private directory by executing the “ecryptfs-mount-private” terminal command in C++ and providing the passphrase/password from the same C++ script. I have tried forking then exec the shell (/bin/sh) and opening pipes for I/O with sh but when I try to write through the pipe I get the following error: stty: standard
Trying to use Boost 1.69.0 from CLION while Visual Studio works, but giving weird MINGW errors
Visual Studio is aweomse. It works, but I like using CLION and has no debug feature, so I try to use MINGW, but I get this weird undefined reference errors. My CMakeLists.txt: So now from this part it builds and works with Visual Studio, but given I try to debug with CLION, I try to use with MingW (besides I
Code works logically on macOS but not on Ubuntu 16.04.5
I have a task to write the function: int read_palindrome(); // input comes from stdin which will read one line from standard input and returns 1 if the line is a palindrome and 0 otherwise. A line is terminated by the newline character (ānā) and the does not include the newline. There are requirements to be met: There is no
Reference assemblies for framework “.NETFramework,Version=v4.7.1” were not found
I try to open a Unity3D project with VSCode under Linux (Ubuntu 18.10). The omnisharp extension doesn’t load the project, saying assemblies were not found. It may seems very stupide, but i’m not really used to .Net yet, and i have been stuck with this error for quite some days now. I have been trying re-installing dotnet (even using the
How can I accomplish multiple threads to join multiple times into a process? (pthread_mutex_lock)
I want to write a program, what counts to 100. I want to accomplish this with 10 threads, using pthread lock. When the program steps into a thread it generates a number between 0-2, this value will be added to it’s index of array and also to the global variable sum. When the sum value reaches 100, every thread should