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

1
vote
1answer
32 views

Compiling sources with a non-default compiler

I need to implement an authentication scheme on an embedded device and require gmp in order to perform large integer operations. After downloading the sources they must be compiled with a proprietary ...
0
votes
0answers
29 views

custom gcc install include files

I have a custom installation of g++ 4.8.1 in my home directory. However the include files in that installation have no extensions! (except for tgmath.h, fenv.h, complex.h, and cxxabi.h) Thus even if ...
0
votes
1answer
10 views

How to determine which Berkeley DB version is used for RPM's database?

I am attempting to read and write the RPM database located in /var/lib/rpm under CentOS 5, and eventually other system types (CentOS 6, RHEL, etc.) The problem is that I don't know what version of ...
0
votes
1answer
25 views

How do I check if FFTW installed correctly?

I tried to install FFTW on my system (Ubuntu 12.04) using the rather unclear instructions on this website, and now I want to check if it worked. (FFTW is a C subroutine library for computing the ...
0
votes
0answers
30 views

I can fix/repair small damaged tar.gz files using fixgz but it doesn't work on bigger files

The title tells it. I have some damaged .tar.gz files, most of them are pretty small (smaller than 1-2gb) but 4 of them are bigger and fixgz cant fix them, when i run fixgz for those big files, it ...
0
votes
3answers
62 views

Are there obvious differences between learning C on OSX and learning C on Ubuntu?

I'm a python programmer, and today I start my journey of C. Now I'm using OSX, with Ubuntu in my Virtual machine, meanwhile our production servers are using CentOS. I suppose these three systems ...
1
vote
3answers
271 views

How to calculate the memory consumed by a “C” program in linux

I have written two C programmes one is using function pointer, and the other without function pointer. Now i want to know the memory consumed by the two programmes , to see how memory can ...
0
votes
0answers
51 views

how to increase Stack Size of a running program in C

I am trying to identify any way if we can increase the stack size of my running program after getting SIGSEGV. I know we can increase the size of stack by ulimit -c but, that did not solve this ...
-1
votes
0answers
19 views

How Can I recieve messages from more than one named pipes? [closed]

I have to use fifo in my code. I use sock to accept new client. For each client I create new thread to send and recieve message to him. In the function of the thread I use fifo to send and recieve ...
-2
votes
1answer
33 views

Meaning of '&' in C (here in linux kernel function-like Macros) [closed]

#define TCP_SKB_CB( __skb ) ((struct tcp_skb_cb *)&((__skb)->cb[0])) What does the & mean in this context?
3
votes
2answers
56 views

When does cat finish reading from a pipe?

Given the following code, why does cat only print the contents of the pipe after I've typed \n or CTRL+D? What are the conditions for cat to actually print what it read? #include <stdio.h> ...
2
votes
1answer
87 views

How can I (easily) map a block device node to the directory it's mounted on?

I need to find (in C or C++) the used space on a filesystem (Linux) when being provided only with the disk block device name and the partition number. For most filesystems I can go: Craft a dev ...
3
votes
1answer
57 views

Memory layout of dynamic loaded/linked library

when loading a shared library in Linux system, what is the memory layout of the shared library? For instance, the original memory layout is the following: +-----------+ |heap(ori) | +-----------+ ...
3
votes
1answer
47 views

Io redirection vs file logging performance c/c++

Is there a performance difference from a latency point of view if we do a regular printf and redirect stdout to a file when running the program ( e.g., ./a.out > log.txt 2>&1 ) vs using fprintf ...
0
votes
1answer
30 views

Can I use LXC library in my c program?

Currently, I am designing a c program that will create multiple container and put different applications into them separately to achieve isolation. Is it possible to leverage LXC library to it? I ...
4
votes
1answer
470 views

Can I write C programs for Linux on OS X?

In case I'm writing a program (of any kind) in C, that is meant to be run on Linux environment, can I write it under OS X? (concurrency wise for example) I'm asking this because I like programming in ...
3
votes
2answers
204 views

The «sh» being launched with execl() becomes a zombie

I am spent whole half a day, but still couldn't figure, why is the dash being launched with execl call just becomes a zombie. Below is a minimal test case — I'm just fork a child, make a duplicate of ...
0
votes
1answer
27 views

What happens to TCP when a write fails to enqueue with the device tx ring?

Lets say the device tx ring is full and you do a normal C non blocking write(fd, buff) to enqueue data in the TCP SND buffer. What happens when this fails? In UDP - the packet would be dropped but ...
1
vote
1answer
27 views

Distributing app with .so files?

I'm trying to make a game in C with SDL and OpenGL. Q: Will my game run on computers without SDL installed if I ship the .so files in my game folder? I mean adding the .so files somewhere in the game ...
4
votes
1answer
447 views

why is “timer_t” defined in “time.h” on Linux but not OS X

While I was reading a C source code files, I found this declarations. (This source code was written for linux system program. This is very important information) #include <time.h> #include ...
1
vote
0answers
87 views

Reading the program header contents of an ELF file

How is it possible to extract loadable program headers individually from ELF files? By examining a binary using readelf one can get output similar to: $ readelf -l helloworld Elf file type is EXEC ...
0
votes
1answer
50 views

introduce a c script in a bash file [closed]

My problem is to recover data keyed in text file in bash. I seek the command that can perform this task and I used sed, awk and even cut but I have not succeeded. One friend of mine suggested to ...
0
votes
1answer
42 views

How do I execute a parted command with a C function?

I would like to execute the Linux command "parted" through a C language function? I am using Linux Ubuntu , eclipse. Thanks!
0
votes
0answers
20 views

How to obtain block device label [duplicate]

I have a tricky problem. I have a block device connected to SLES11, it is present in /proc/partitions but it is not mounted (not present in /proc/mounts). From C code I want to find the block device ...
1
vote
1answer
311 views

Reading the contents of an ELF file (programmatically) [closed]

I am trying to retrieve the contents of an additional section within an ELF binary. At this point, I'm using the following code to retrieve the name of each section: #include <stdio.h> #include ...
0
votes
2answers
46 views

Pulling log messages for a particular log in systemd journal?

I was wondering if it is possible to pull log messages for a particular log with systemd's journal logging. For example, when I open a log in C, openlog('slog', LOG_CONS | LOG_PID, LOG_LOCAL1), to ...
1
vote
1answer
70 views

How to run smartctl as root without switching to root?

I have this C code that runs smartctl command and takes its output: #include <iostream> #include <cstdio> #include <cstdlib> using namespace std; int main() { cout << ...
0
votes
1answer
90 views

Trying to make a Universal Makefile

I'm working on my own netfilter module for the first time. According to internet documentation, The simplest module contains the following C code: //'Hello World' kernel module, logs call to ...
1
vote
3answers
112 views

loop test strings to see if input is valid for C program input

For example I have a file filled with some pretty gnarly strings. 12345678900 1111111111111111111111111 ...
0
votes
1answer
239 views

C/C++: Running multiple commands as root

I want to execute commands within my C program. However, I need root priviliges to create some folders. I run the following: system("echo <rootpass> | sudo cd <folder> && make ...
-2
votes
1answer
109 views

how to return file descriptor in c [closed]

I am confusing with this. fp=fopen(filename,mode); what is the value fopen() return to fp. is that value is file descriptor integer? is fp called as stream ? if not how to return a ...
0
votes
1answer
78 views

How to select read/write time and again? [closed]

This program only waits one time and I don't understand why. Actually, I don't think this question should be put on hold as off-topic. #include <stdio.h> #include <sys/types.h> #include ...
2
votes
2answers
66 views

linux setuid does not work

I am learning linux suid,so I have written a small c program with the following content to test it #include<stdio.h> int main(){ system("echo 100 >> test.txt"); return 0; } -rwsr-xr-x 1 ...
0
votes
1answer
2k views

“fatal error: stdio.h : No such file or directory” while compiling a C file [closed]

Trying to compile following code in terminal i got root@debian:/home/mz2/Documentos# LANG=C ./soma.c ./soma.c: line 2: syntax error near unexpected token `(' ./soma.c: line 2: `int soma (int a, int ...
0
votes
0answers
56 views

keyboard still working after calling free_irq(1, NULL);

I'm developing a kernel module which free the IRQ number 1 in order to disable the keyboard in Intel architectures. according to wikipedia the IRQ 1 is used for keyboard. but after building and ...
19
votes
4answers
2k views

How to dump a binary file as a C/C++ string literal?

I have a binary file I would like to include in my C source code (temporarily, for testing purposes) so I would like to obtain the file contents as a C string, something like this: \x01\x02\x03\x04 ...
0
votes
1answer
46 views

how to define the top dir in automake system?

I usually use a typical steps to generate the makefile, and firstly I use the "build.sh init" to generate the configure file, and then I use "configure" to generate the makefile with makefile.am file. ...
0
votes
1answer
964 views

Cabal error: Cannot run c compiled programs

I have an old version of cabal-install so I downloaded cabal-install 1.20 and When installing it errors out. Additional note: ghc 7.8.3 OS: CentOS 6.6 Error: Building network-2.4.2.3... ....... ...
1
vote
1answer
312 views

Cannot find -lgcc

I'm trying to compile my next basic c program after hello-world. This contains two supporting modules. I have Ubuntu running in a VM through VirtualBox on a mac. Everything is up to date but I ...
1
vote
0answers
2k views

Getting “cannot open shared object file: No such file or directory” error while run time

I have successfully compiled the file but now I am getting following errors export LD_LIBRARY_PATH=/opt/mcr/v717/sys/java/jre/glnxa64/jre/lib/amd64/server/:D_LIBRARY_PATH ./invoke ./invoke: error ...
0
votes
1answer
29 views

-fPIC Flag System-wide?

Position Independent Code means that the generated machine code is not dependent on being located at a specific address in order to work. and the jumps are relative. So is it OK to declare -fPIC ...
2
votes
1answer
100 views

How to compile manual files .1

I have .c, .h, and .1 files, how can I compile them together in one executable file. Everything clear with .c and .h files, but I have also .1 as I can see from the content it is used for manual, how ...
1
vote
2answers
130 views

How can I link my C program against the Arb library?

I tried to compile the program Testing Li’s criterion in Ubuntu. However, when I do gcc demo.c, I get the output as, demo.c:2:19: fatal error: fmpcb.h: No such file or directory #include "fmpcb.h" ...
1
vote
1answer
534 views

Linking a static library when compiling a C program

I'm linking *.a file with *.c file, so I have used the following command: gcc abc.c -l ad.a (here abc is the C source file and ad is the static library file) then after executing the following ...
3
votes
1answer
135 views

Read .desktop files programmatically [closed]

I would like to make a C program (GTK) that reads a .desktop file. The only thing I need from the .desktop file is the exec command. Is there something built into GTK that would allow me to interact ...
2
votes
2answers
135 views

assign output of a c program to a shell variable: token error

I have a shell script to run several times a .c program ('switch') which admit 3 input paramenters. I want to run the program 4 times passing values {4,16,32,64}, and for parameters ...
4
votes
2answers
3k views

How to check whether a process is daemon or not?

I have written a small daemon that starts at the boot time and does all the things perfectly like writing in the log file. But I want to know, how can we check whether that process is daemon or not? ...
0
votes
1answer
138 views

Linux [admin] How to test pivot_root?

I want to test the pivot_root command line, which moves the root file system of the current process to the directory put_old and makes new_root the new root file system. ...
1
vote
1answer
35 views

snd_rawmidi_open() waits forever - no error message

I am trying to use ALSA for MIDI purposes in C. My problem is, snd_rawmidi_open() sort of "crashes" (waits forever like a while loop) when using valuable arguments : #include <stdio.h> ...
2
votes
0answers
47 views

Make GNU indent break long comments

Is there a way to convince GNU indent to break long comment and change it to multiline comment? Something like this: // Very long comment, longer than 80 characters. Just imagine that. To this: /* ...