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
407 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 ...
-2
votes
0answers
29 views

Which language is the “best” for Linux development? C, Go, or Python? [on hold]

When I refer to C, I'm talking about C11 and not ANSI C. Alright so a few months back I got really interested in Linux and played around with Ubuntu, Mint, Fedora, Lubuntu, and a few others. Then for ...
1
vote
0answers
26 views

How to execute bash commands from C? [migrated]

Is there a way to run command line utilities, e.g. gzip, into a C app?
0
votes
0answers
16 views

quick question about kernel modules [migrated]

I'm very familier with linux (been using it for 2 years, no windows for 1 1/2 years), and i'm finally digging deeper into kernel programming and I'm working a project. So my questions: Will a kernel ...
2
votes
2answers
179 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
14 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
17 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 ...
0
votes
0answers
25 views

How should my program behave to handle errors? [migrated]

I have written a program (with code from SO) that does printenv | sort | less and now I should implement error-handling. How can that be done? The program should fail gracefully, for example when ...
4
votes
1answer
298 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
50 views

Execute sudo command in C with system() [migrated]

I am writing a piece of C code that will run some sudo command in system("sudo ip route ...") function call. This call is being done in a pthread created by the main thread, and the main program is ...
0
votes
0answers
10 views

c server handle multiple connections, error on port no [migrated]

I've been experimenting with server code from http://www.linuxhowtos.org/C_C++/socket.htm. The regular server code worked fine, I've changed it slightly to hardcode in a port number rather than read ...
-1
votes
0answers
14 views

Rot13 implementation: error in translate_string function [migrated]

I wrote a rot13.c program but I can tell something in my loop inside rot13_translate_string is causing the program to just print out blank lines. Any thoughts? Thank you! #include <stdio.h> ...
1
vote
0answers
52 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
43 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
36 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
19 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
198 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
1answer
27 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
40 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
48 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
76 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
118 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
65 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
58 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
62 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
736 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
44 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 ...
17
votes
4answers
1k 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
0answers
24 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
583 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
196 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
1k 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
21 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 ...
1
vote
0answers
49 views

Linux and Embedded systems engineering [closed]

First of all I hope everybody had a great weekend. My question is simple. Which version of linux is best suted for embedded software engineering and programming. Thank You AO!
2
votes
1answer
93 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
117 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
294 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
128 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
109 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
2k 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
108 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
0answers
92 views

PAM authentication program in C recognizes only the logged in user [closed]

I am trying to write a C program to authenticate users using PAM. Here is what I have at present: #include <security/pam_appl.h> #include <security/pam_misc.h> #include <stdio.h> ...
1
vote
1answer
27 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
39 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: /* ...
2
votes
2answers
597 views

Linux cannot compile without GCC optimizations; implications? [closed]

One can find several threads on the Internet such as this: http://www.gossamer-threads.com/lists/linux/kernel/972619 where people complain they cannot build Linux with -O0, and are told that this is ...
4
votes
1answer
134 views

How to compile programs on Linux systems when I don't have sudo privileges to install the dev dependencies [duplicate]

How should I go about compiling programs that depend on libraries whose development packages (headers and such) aren't pre-installed on the system when I don't have sudo access? In this particular ...
0
votes
0answers
34 views

Inotify notifies only single change

I set the inotify_add_watch to watch /dev/disks. The entries in this directory are: by-id and by-uuid. When I plug-in a pen-drive, this directory gets added with two more directories: by-path and ...
3
votes
1answer
259 views

How to create GUIs (such as menuconfig) with lxdialog

I try to generate a menuconfig by my own with the help of lxdialog (source: lxdialog). Unfortunately this is not so well documented as I wished for. Example: So what I did: I included these files ...
1
vote
0answers
34 views

CPUFreq Kernel module

I would like to try the CPUFreq module on my board (Marvell Soc based on ARMv7 running a v3.15 linux kernel). My architecture is obviously not supported by the default source code (located in the ...
5
votes
4answers
2k views

chdir(<directory>) doesn't change directory after exiting to shell

I wanted to make a simple C program to change to my project directory. Its content is following: #include <unistd.h> int main(){ chdir("/home/enedil/projects/algo"); return 0; } I ...