Skip to content
Advertisement

Tag: c++

Comparing 2 files in c linux fgets

I need to compare 2 files and return 1 if they are same or 0 if not, but function always return 0. I have no idea why. Maybe you know diferent function that can do this. Answer strcmp(line1,line2)==0 means line1 and line2 are equals, your code supposes they are different There is an other error, if a file is starts

Unable to connet to SQL server using soci library

I am beginner in c++,my problem on Linux for connecting to SQL Server with soci library, my code this but I have error and I don’t found solution for my problem, my code this: I have error: Here is the code: Answer Your ODBC connection string in incorrect, your first parameter specifies a datasource called “ODBC”, which you haven’t configured

Adaptation from old init_timer to new timer_setup

I have been trying to port a driver from 2.6 to 4.X without support from the original board manufacturer (and very limited Linux experience). The original driver uses init_timer() and passes in a pointer to the timer_list structure. That timer_list structure’s data element was set to a pointer to another memory structure and the function element set to the callback.

How to pass an extra option in ls using execv()?

I’m trying to execute this simple command ls -1 *.c using the execv() function. The output I’m getting is Answer There’s a big problem in your code: execv can’t tell how big the array you’re passing it is. You absolutely need a terminating NULL element to mark the end: OK, now that we have a valid execv invocation, we can

How to avoid read() from hanging in the following situation?

I have some code that forks a third-party application and redirects its standard output to the parent process, roughly as follows (no error handling here for brevity): I have no code for the third-party application, it is a proprietary binary. When running the third-party application in a terminal with the same arguments as used in the code above, it eventually

Why is linear search so much faster than binary search?

Consider the following code to find a peak in an array. If I compile with -O3 and use the linear search solution (the peak function) it takes: If I use the binary search solution which should be much faster (the peak_rec function), it takes: I tried turning off optimization but this didn’t change the situation. I also tried both gcc

read() hangs on zombie process

I have a while loop that reads data from a child process using blocking I/O by redirecting stdout of the child process to the parent process. Normally, as soon as the child process exits, a blocking read() in this case will return since the pipe that is read from is closed by the child process. Now I have a case

Towards understanding availability of xdg-open

I want to open an image, and in Windows I do: I would like to use a Linux approach, where it’s so much easier to run something on the fly. Example: In my Ubuntu, it works. However, when running that in Wandbox (Live Demo), or in any other online compiler, I would most likely get an error: sh: 1: xdg-open:

Advertisement