Skip to content
Advertisement

Tag: c++

Understanding the output of gettimeofday

I am trying to understand the precision of the gettimeofday() system call. Here’s my program: The output if I run this program (./a.out 10) is, The seconds column seems to reconcile with the sleep of 1 secs. Can someone please explain what’s going on with the values in micro seconds column? It looks like the jumps from sleep to sleep

What does the z component of ncurses mouse events represent?

From ncurses.h What does the z coordinate represent? Answer From the curs_mouse man page: The z member in the event structure is not presently used. It is intended for use with touch screens (which may be pressure- sensitive) or with 3D-mice/trackballs/power gloves. Also, if you search lib_mouse.c in the ncurses source code for ->z and .z, you will find that

Close file in C

Under Linux I use this code to redirect stdout and stderr on a file, as shown in the code the file is opened using fopen(f) and is it closed using close(fd). My question is whether the close(fd) statement closes all file descriptors, or is it necessary to use fclose(f) as well ? Answer The rule is to close the outermost

Why am I receiving segmentation fault (core dumped)?

This program was created to log the counter every 5 seconds. The while loop needs to be running while the daemon process is running in the background and logging the counter. The error I’m receiving is: Segmentation fault (core dumped). the terminal ask to input a number, when I input the number I receive the error. I think the while

Is -D_LARGEFILE_SOURCE needed on modern Linux

I’m looking at a very old C based project. It adds the -D_LARGEFILE_SOURCE define when building. Is that preprocessor macro still needed on modern Linux (and if so, why)? Answer I checked the headers. If you are compiling for 64 bit, _LARGEFILE_SOURCE will be defined for you every time. This only does anything for 32 bit. And yes this is

Azure Batch Service: Passing Arguments via Command Line into Application Package on Linux/Ubuntu

Given the following C#/.NET console application running on my Azure Batch Pool/Task: How can I pass the args when adding a command line to my tasks in a Linux/Ubuntu VM. I have tried the following with no success: /bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program -args ‘arg1’ ‘arg2’ /bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program -args ‘arg1’, ‘arg2’ /bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program ‘arg1’ ‘arg2’ /bin/sh -c $AZ_BATCH_APP_PACKAGE_Program_1_0/Program ‘arg1’, ‘arg2’

Advertisement