C is a general-purpose computer programming language used for operating systems, games and other high performance work and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.

learn more… | top users | synonyms

4
votes
1answer
2k views

Writing to stdout except for output redirection C

I have to make a simple app for school. I have to write arguments one per line on the terminal, and return on stdout the user choices. For example, I write cat my_app main.c main.h, if the user ...
5
votes
4answers
898 views

Error while loading shared libraries

My project tree looks something like that: src/ include/ Makefile lib/ lib/3rdparylib/ I didn't code 3rdpartylib, but decided to embed its source code in my project packaging. I compile the ...
2
votes
1answer
1k views

gcc: -pthread: No such file or directory

Trying to compile following code in terminal i got gcc: -pthread: No such file or directory, what does this error means and how to eliminate it? file name: window.c code: #include ...
8
votes
1answer
2k views

While there is C++ why most of Linux programs are written in C?

Why most of linux programs are written in C? Why they are not written with C++ which is newer than C?
0
votes
2answers
330 views

Why Samba needs the VFS module?

I came across this picture when learning samba. I am confused with the VFS module in this image. Why we need this VFS module in samba server instead of passing directly the intend system call to ...
3
votes
3answers
255 views

“which” equivalent for shared libraries

I am looking for a utility that would behave in the same way as which, but to look up shared libraries (*.so) in the directories defined in $LD_LIBRARY_PATH?
6
votes
2answers
159 views

System programming: How to gather info?

According to this question, a good way to learn system programming would be to implement the existing tools. I decided to try to rewrite ls and ps. My question is how would one proceed to get ...
5
votes
2answers
3k views

Get CPU utilization stats from C program

I want to read the CPU utilization stats from a C program, I am interested in the percentage of use of CPU, steal time etc. These stats are shown in the 3rd row from the top command. I tried to parse ...
2
votes
1answer
1k views

How to capture from instensive pro in Ubuntu, Fedora, CentOS using HDMI interface?

I am trying to use PCI-X1 capture card (intensiy pro) using Ubuntu 10.04 (now) / 11.04 (failed) or Fedora (failed). None of them is yet capturing. I did my best but now i need some backup on this. ...
4
votes
2answers
4k views

“sys/ioctl.h” header in linux

I am on Linux 2.6.32-26-generic When I look in to the linux source code for "ioctl.h" hearer file, I could see many variants. (for different platforms, I guess). i.e. ./fs/ocfs2/ioctl.h ...
14
votes
3answers
8k views

What are pseudo terminals (pty/tty)?

This might be really basic question but I want to understand it thoroughly. What is a pseudo terminal? (tty/pty) Why do we need them? How they got introduced and what was the need for it? Are they ...
2
votes
3answers
1k views

Fork: Negative return value

From the fork(2) man page: RETURN VALUE On success, the PID of the child process is returned in the parent, and 0 is returned in the child. On failure, -1 is returned in the parent, no ...
5
votes
3answers
3k views

How do I kill all a user's processes using their UID

I want to kill all running processes of a particular user from either a shell script or native code on a linux system. Do I have to read the /proc directory and look for these? Any ideas? Is there a ...
0
votes
3answers
166 views

What to change to place text in the centre of the screen [closed]

The following program will clear the screen #include <stdio.h> int main() { fputs("\033[2J", stdout); return 0; } So, what should I modify/add in the above code to put a text string ...
5
votes
4answers
813 views

Does optimizing for size reduce runtime memory usage as well as binary size?

Does optimizing for size with gcc -Os only reduce the binary size of a program, or does it reduce its runtime memory usage as well? I know what exactly the results are depend on the specific code, but ...
6
votes
1answer
304 views

Why would one want to compile multiple .cpp files to the same executable?

Why would you do g++ -Wall -I/usr/local/include/thrift *.cpp -lthrift -o something instead of: g++ -Wall -I/usr/local/include/thrift -c Something.cpp -o something.o g++ -Wall ...
0
votes
1answer
3k views

how to Update gcc of OpenSuse 11.2?

I have OpenSuse 11.2 with gcc version 4.4.1. I would like to update my gcc version to 4.5.1. I have downloaded gcc-4.5-19.1.i586.rpm. When I rpm install it, it's asking for ...
0
votes
3answers
4k views

/usr/ucb/cc: language optional software package not installed

I tried to compile some C code to get object file from a shell prompt: $cc a.c But this gives me the following error: /usr/ucb/cc: language optional software package not installed How can I ...
6
votes
3answers
5k views

Man pages for standard C and C++ libraries on Fedora 14

How do I install them? At present, man fopen gives me No manual entry for fopen. I have the compilers installed and have verified that things do build without problems. Update: This is what I got ...
6
votes
4answers
8k views

make a log file

Is there any way to make a log file for maintaining some data in /var/log/ with the help of some library function or system call in c language in linux. And I also want to know the standards that we ...
3
votes
2answers
316 views

Is there a glibc API that can find the default handing application for a MIME type on linux?

I want to find the default handling application in my C program. Is there a C API with same functionality as xdg-mime query default mime-type on Linux?
6
votes
1answer
228 views

Executing a shared library

Some shared libraries provide an output when called from the command line as if they were executables. For example: $ /lib/libc.so.6 GNU C Library stable release version 2.13, by Roland McGrath et ...
4
votes
2answers
1k views

Implementing a Unix shell in C: Logging

I am currently working on implementing my own UNIX shell in C. The basis of the shell is working, you could find the source code here. Right now my next task is to implement a logging feature for the ...
8
votes
4answers
2k views

Why should a child of a vfork or fork call _exit() instead of exit()?

From the man page of vfork(): vfork() differs from fork() in that the parent is suspended until the child makes a call to execve(2) or _exit(2). The child shares all memory with its ...
11
votes
4answers
3k views

After fork(), where does the child begin its execution?

I'm trying to learn UNIX programming and came across a question regarding fork(). I understand that fork() creates an identical process of the currently running process, but where does it start? For ...
1
vote
1answer
261 views

Recording and charting boot process information in Linux

I need to write a command line tool that records the boot process information in Linux, and then renders it in a chart format (a textual chart would do). How do I programmatically obtain the this boot ...
6
votes
5answers
3k views

Develop / Debug C / C++ on Ubuntu?

What's the best IDE for developing C / C++ on Ubuntu? I tried installing Eclipse but it seems like I need the eclipse-cdt package also. The problem is there is no such package, at least for Lucid. ...
3
votes
1answer
3k views

Error when using stat, errno=2

The case is as this, I create many files, and after the file generation, I use stat to get the all files info under the directory. The purpose is to purge all the files which are old than the ...
5
votes
1answer
2k views

How can i know which unistd.h file is loaded?

I have several unistd.h files in my Ubuntu Linux. I've one on: /usr/include/asm/unistd.h This file has this directives: # ifdef __i386__ # include "unistd_32.h" # else # include "unistd_64.h" # ...
7
votes
10answers
1k views

Development environment for C

Looking for ideas on setting up a convenient and productive development environment for C development. I found C editing with Vim very helpful but I would like to get a wider sampling of suggestions.