Skip to content

Tag: c++

SIZE command in UNIX

The following is my C file: It contains only return statement. But if I use the size command, it shows the output like this: Even though my program does not contain any global variable, or undeclared data. But, the output shows data segment have 252 and the bss have 8 bytes. So, why the output is like this? w…

Child process starts after parent process

I have a simple code to test the fork() function. It didn’t work as I expected. My expectation is: parent’s result and child’s result appear alternately. Can someone explain this and teach me how to fix it? Thanks! Answer The explanation is simple. Scheduling of processes is up to the kernel…

How fork() function works in this program?

I’m having some trouble with this program. I know what a fork() function does. It is used to create a new process from an existing process. The new process is called the child process, and the existing process is called the parent. The parent returnes the child’s pid and the child returns 0. That …

Redirect stdout to a external program in C/C++

I have a program called capture that reads the webcam data and output to the avconv program. Now I have to output to avconv inside my C program. So, instead of output to the stoud: I need to do do something like that: How can I do that? Answer You can use popen() for this purpose. then use fwrite() to

SEGFAULT after recv from socket

I have next trouble: after receiving data from sockets, server app generates segfault and shutdown. Code of client and server side are below. server: Client: In other words, client connected successfully. But after sending message, server generate segm fault error. What went wrong? Answer When running the cod…

makefile linking does not work (although no error message)

I am having issue with Makefile that I produced. It consists of one .cpp file with main() inside and I want to create executable from it. While putting in terminal make command I get following: While putting first make STutorial.o (.o created) and then make get this: Firstly, why make does not go from the beg…