Skip to content

Tag: c++

Message queue: msgsnd failed : Invalid argument

Can anyone please help me to point out as what is the error in my program? Thanks in advance, kingsmasher1 Output: msgsnd failed: Invalid argument Answer You do not have enough space in your buf.mtext (15 characters) for “This is a test message” (23 characters plust one more for a NUL terminator).…

Paint Pixels to Screen via Linux FrameBuffer

I was recently struck by a curious idea to take input from /dev/urandom, convert relevant characters to random integers, and use those integers as the rgb/x-y values for pixels to paint onto the screen. I’ve done some research (here on StackOverflow and elsewhere) and many suggest that you can simply wr…

What are the GCC default include directories?

When I compile a very simple source file with gcc I don’t have to specify the path to standard include files such as stdio or stdlib. How does GCC know how to find these files? Does it have the /usr/include path hardwired inside, or it will get the paths from other OS components? Answer In order to figu…

using C code to get same info as ifconfig

Is there a way in Linux, using C code, to get the same information that “ifconfig eth0” would return? I’m interested in things like IP address, link status, and MAC address. Here’s sample output from ifconfig: Answer Yes, ifconfig itself is written in C. 🙂 See: http://cvsweb.netbsd.org…

Resetting an ostream, C++

I have 2 different ostreams, one of them cerr, using the same streambuffer, I have some libraries in that might have modified cerr somehow,(flags? format modifiers?). prints: Debugging mystreambuffer I’ve noticed that cerr calls mystreambuffer->sync() every << operation while teststream does no…

Socket data length questions

I have a couple of questions related to the following code: The questions: Why I read 255 not 256 ? Let’s say I want to send the word: “Cool” from the client to the server. How many bytes should I write “in client” and how many bytes should i read “in the server”? I&#…

I cannot get stdout to update in Qt

I need to call an executable, from my QT application, monitor the output and then display the out put in a text browser. The executable I call from my QT app will run for many hours (~12) and each time the executable spits something out to stdout, I need to parse the output to be able to monitor its progress,