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.
Questions tagged [c]
849 questions
38
votes
3 answers
Single '#' in old C files
I started studying old C code (Unix v6) and I'm wondering what is the purpose of a single # in the beginning of the .c file. For example from https://github.com/lsahn-gh/unix-v6/blob/master/sys%2Fken%2Falloc.c
#
/*
*/
#include…

g0mb4
- 701
26
votes
7 answers
Possible to find out the sizes of data types (int, float, double, ...) on a system, without writing a C program?
Is it possible to find out the sizes of data types (int, float, double, ...) on a Linux system, without writing a C program?
Would the results for C same as for C++, and other programming languages in the same Linux system?

Tim
- 101,790
9
votes
5 answers
Print all C comments to a separate text file
I would like to print all my C comments to a separate text file.
Using awk, sed, grep, or bash
output all multi-line C comments between /* ... */ (inclusive)
output lines with // comments
Optional: print line numbers
I tried these solutions but it…

jwzumwalt
- 259
2
votes
1 answer
Are there any disadvantages to using openat() for path resolution?
The man page for openat(2) describes a lot of its advantages compared to open(2), but it doesn't seem to include any sort of disadvantages.
Concatenating paths in C manually can be a pain (assuming one doesn't want to / can't offload most of the…

Érico Rolim
- 23
1
vote
3 answers
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 have differences on their C libraries.
So should I…

Zen
- 7,537
0
votes
1 answer
error: 'struct msghdr' has no member named 'msg_accrights' is the message while compiling C program
Migrating from Sun Solaris to RHEL. But while compiling the C program getting the following errors.
struct msghdr msg;
msg.msg_accrights = (caddr_t)&fd_to_send;
msg.msg_accrightslen = sizeof(int);
error: 'struct msghdr' has no member named…

ray
- 1
0
votes
1 answer
How to display the content of a file using pipe?
I have a text file and I should display its content using pipe in a C program. I have made something like this but isn't exactly what I need.
#include
#define MSGSIZE 16
char *msg1 = "hello, world #1";
char *msg2 = "hello, world…

Vv_Ff
- 1
0
votes
1 answer
Compiling early C, with arguments declaration under the function name
I found some early C sources code, that I wrote, in the days I was beginning C, in 1987.
C is written with declarations of this kind:
myFunction(c, v)
char c;
int v;
{
...
}
And I wonder if there is still a compiler available on Linux today (I'm…

Marc Le Bihan
- 1,797
0
votes
1 answer
How to avoid compatibility issue Segmentation fault (core dumped) with memory address
I am trying to hack the general C rules while research and try to store memory address in variable but my code failed with Segmentation fault (core dumped) when running under 64-bit system. And I know why - because of 4/8-bits (32/64-bit systems) of…

storenth
- 101
0
votes
0 answers
Undefined symbol when executing compiled binary, although readelf shows the symbol with the right version
I have compiled the vagrant-libvirt plugin following the instructions here:
https://github.com/hashicorp/vagrant/issues/7039#issuecomment-488499883
It compiles fine, but at runtime I get the following error:
3: from…

Manu
- 576
0
votes
1 answer
GCC Compiler Error Again
I was once again trying to install a compiler onto my SGI Indy computer running Irix version 6.5, and this time, I found a file that has all of the libraries I thought I would have needed. When I compiled, I get an error that says
cc1: rld: Fatal…

rjhwinner03
- 11
0
votes
0 answers
Millisec. in filename with C
I find no indication that there is a format for milliseconds in C.
I save images more than once a second and need an additional index.
My code now is:
time_t now;
struct tm ts;
time(&now);
ts = *localtime(&now);
strftime(buf, sizeof(buf),…

ThomasDr
- 19
0
votes
1 answer
How to detect and get the real size of device files?
The C fsize function returns 4096 for special/device files, but is there an integrated function to know the real size of a device file if it is finite ?
I would also like to know if there is a way to know whether a file is a regular file or a device…

Pop Flamingo
- 129
-1
votes
1 answer
Byte swap question (Bitwise operation)
I have seen some bitwise operation practice questions (in C language) and there was one I didn't understand: you had to swap the nth and the mth byte in a specifc integer "x" using only bitwise operations, and that n and m were both <=3. The…

Goodwin Lu
- 83
-2
votes
1 answer
Regarding declaring array in c
Whenever I create an array in C using sublime text editor I get following error
The code written is: