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

0
votes
0answers
6 views

MUMPS - The MPI_Comm_f2c() function was called before MPI_INIT was invoked [migrated]

I need to use MUMPS in my project. I wanted to test the installation with the simple example of solving equations (below). The problem is, that this code works correctly in my personal PC, but it ...
3
votes
0answers
274 views

Monitor if a process has terminated in C [migrated]

Introduction I am writing a monitoring program in C, which performs the fork() and exec() cycle. However I need to check whether the child process has terminated or not without blocking the main ...
0
votes
1answer
29 views

Two or more threads on single core [on hold]

What are the advantages of using threads on single core, does that makes sense to use multithreading on single core?
0
votes
1answer
38 views

Why is my CD command not working on a home-built shell? [duplicate]

I have written a very basic shell in C. It reads the input, then runs it using system(lineCopy); (lineCopy being a copy of the input). All commands will run fine in it, other than cd. When I try to cd ...
-5
votes
0answers
21 views

How can we increase the number of arguments? [on hold]

For the program like #include "apue.h" int main(int argc, char *argv[]) { int i; for (i = 0; i < argc; i++) /* echo all command-line args */ printf("argv[%d]: %s\n", i, ...
-1
votes
2answers
101 views

Free or cheap shell (i.e., platform) to run a Linux C program with root privileges (raw socket)

I'm working on a Linux C program that needs root privileges (raw socket). I would like to run it on a host located in the US (I am in EU) to compare results. Is there any free (or cheap) shell ...
-1
votes
1answer
14 views

Daemon opens a file in RO mode only

I am trying to write a kind of keylogger myself. I don't know if my logic of developing a keylogger is good or not but I have thought of doing it the following way. First a daemon is created, and to ...
1
vote
1answer
33 views

Undefined reference to math functions when linking with gcc

I'm getting an error when using make to install a program. The full step that it fails on with error looks like this: gcc -g -O2 -fopenmp -L/usr/lib -lcfitsio -lm -o lenstool_tab e_nfwg.o ...
-3
votes
0answers
30 views

Need help with this piece of code plz [migrated]

i have this piece of c code below and whatever value i give to code[] , i m getting Segmentation fault(core dump) . Do you have any ideas why this happens?.Thanks in advance char code[] = ""; int ...
-2
votes
2answers
44 views

How to find only the name of a link? [closed]

Specifically, I need to write a C program where I put inside the pathname of a symbolic link and on output I print only the name of that symbolic link(not the name of the file pointed by the link). ...
1
vote
1answer
42 views

Cross compiling a software module

I'm trying to compile dropbear with the GNU ARM tool chain. I've went through this guide and managed to successfully build all the required tools. They are located in a directory: ...
0
votes
0answers
30 views

Segmentation Fault in C when Opening Directory [migrated]

I'm using dirent.h to read entries in a directory. I used gcc to compile the code. If pdre is defined, I get a segmentation fault when I open the directory. But if I add a reference to &pdre ...
0
votes
1answer
23 views

Linux server as a target for my C code [closed]

How to use a linux server as a target for my C code written on a different (Windows) machine. Including step by step debugging and etc... All that with Eclipse Env.
1
vote
1answer
73 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
40 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
19 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
39 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
38 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
64 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
344 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
62 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 ...
-2
votes
1answer
35 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
67 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
113 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
66 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
56 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
42 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
493 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
216 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
30 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
37 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
529 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 ...
2
votes
0answers
111 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
47 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
386 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
53 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
82 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
102 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
134 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
253 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
140 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
93 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
61 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
50 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
1k 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... ....... ...