I’m working on a program that needs to store some information and I’ve decided to use a simple file for it. When the program starts it executes the following code, which should result in a file opened in append mode if it exists, or created if it doesn’t (The first time the program loads it should create it in the
Tag: c++
How to interact between webpage and an actual program
What I have: A program (c++) on a server (linux) The program can be executed with command line parameters The program finishes after a while and produces continously output (“log.txt”) What I want: My idea is to have some kind of user interaction with that program: The user opens a website which shows some inputs (checkboxes, etc.) After submitting (POST)
C: finding longest line
I am trying to run this example from (dennis ritchie book), however it does not find the longest line, any idea? main.c other.c other.h Using debugger: looks like i in copyL function does not increment… any ideas why? FIX: Answer I think you incorrectly transcribed the code. This line: is probably incorrect. The expression (to[i], from[i]) is an instance of
Can socket send fail cause a daemon program crash?
I have two applications running on Embedded Linux board. One runs as a daemon and other acts as an interface for it. They communicate with each other using Unix sockets. As to handle any abnormal termination of socket, I tried terminating the interface application [ctr+c]. But as a result, the daemon application crashes. Since the socket is terminated, I get
Why does linking with pthread cause a segmentation fault?
I have a stripped down simple program with a static variable (‘abc.cpp’): I compile it and it works: However, if I link in the pthread library…. I know it doesn’t use threading here, but in the actual non-stripped-down program, it links to a library that does use threading. It feels like it should be okay to link to pthread even
What is the integer value of AF_UNIX?
So, I’m trying to write some JNA code to work with Unix sockets, and I’m trying to reference AF_UNIX for sockets. I looked through some of the gcc included files, but I couldn’t find anything. Answer On my Ubuntu-machine it is defined in /usr/include/x86_64-linux-gnu/bits/socket.h as 1. I haven’t checked around in other Unix source trees, but I have a feeling
How to distinguish between pressed, released and long press when using QAbstractButton::autoRepeat
I am using Qt 4.8.X on Linux with X11 and/or Qt-QWS with custom buttons derived from QAbstractButton. Now I have to distinguish between a button press, release and the user holding down the button. To do so, I would like to use QAbstractButton::autoRepeat as described in this question. As the QT Documentation states If autoRepeat is enabled, then the pressed(),
Modify the return address of a C function with buffer overflow vulnerability
I am trying to modify the following C program so that the main function will skip the printf(“x is 1”) line and only print “x is 0”. As the comments imply, the ret pointer needs to first be set to the return address of the function. I then need to add on an offset that will push it over the
Why my IOCTL call work with copy_from_user but not with get_user?
I am writing a simple driver. Here I’m learning ioctl calls, they work perfect in copy_to_user and copy_from_user part but not in get_user and put_user part. It works if I send some data by those functions; problem is when I have to just pass an integer or character value: in above part it works fine for the copy to user
Linux-C: reading from pipe returns first buffer written to it
This program simulates a variant of Dijkstra’s Producer/Consumer problem. A pipeline is first created followed by a child process using fork(). The child will then write to the pipe a crudely done randomly generated piece of “stock market ticker information”. After waiting for the child/producer process to write this information, the parent/consumer process will read it out. The first output