Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [c]

C is a general-purpose programming language used for system programming (OS and embedded), libraries, games, and cross-platform. This tag should be used with general questions concerning the C language, as defined in the ISO 9899 standard (the latest version, 9899:2018, unless otherwise specified — also tag version-specific requests with c89, c99, c11, etc.). C is distinct from C++, and it should not be combined with the C++ tag without a specific reason.

c
32 votes
5 answers
15k views

How can a C program produce a core dump of itself without terminating?

I want a C program to produce a core dump under certain circumstances. This is a program that runs in a production environment and isn't easily stopped and restarted to adjust other kinds of debugging ...
Joshua Swink's user avatar
  • 3,450
4 votes
7 answers
6k views

Convert console exe to dll in C

I am interested in calling SoX, an open source console application, from another Windows GUI program (written in Delphi naturally). Instead of dealing with scraping and hiding the console window, I ...
Jim McKeeth's user avatar
  • 38.6k
4 votes
7 answers
497 views

How can adding data to a segment in flash memory screw up a program's timing?

I have a real-time embedded app with the major cycle running at 10KHz. It runs on a TI TMS320C configured to boot from flash. I recently added an initialized array to a source file, and all of a ...
AShelly's user avatar
  • 35.2k
1 vote
4 answers
4k views

How do I use scanf() with fopen

I'm writing a program and am having trouble using the scanf and fopen working together. From what I can tell my erroneous lines seems to be: FiLE * DataFile DataFile = fopen("StcWx.txt","r"); scanf(...
user avatar
2 votes
1 answer
2k views

Is there a way to have class variables with setter/getter like virtual variables?

I am embedding Ruby into my C project and want to load several files that define a class inherited from my own parent class. Each inherited class needs to set some variables on initialization and I ...
unexist's user avatar
  • 2,528
1 vote
3 answers
2k views

Debugging with Events in Windows

If I create an event using CreateEvent in Windows, how can I check if that event is signaled or not using the debugger in Visual Studio? CreateEvent returns back a handle, which doesn't give me ...
lazy coder's user avatar
4 votes
18 answers
944 views

Finding the name of a variable in C

I was asked a question in C last night and I did not know the answer since I have not used C much since college so I thought maybe I could find the answer here instead of just forgetting about it. If ...
Primetime's user avatar
  • 579
25 votes
10 answers
14k views

Is it possible to subclass a C struct in C++ and use pointers to the struct in C code?

Is there a side effect in doing this: C code: struct foo { int k; }; int ret_foo(const struct foo* f){ return f.k; } C++ code: class bar : public foo { int my_bar() { ...
Edu Felipe's user avatar
  • 10.4k
29 votes
10 answers
40k views

How can I check my byte flag, verifying that a specific bit is at 1 or 0?

I use a byte to store some flag like 10101010, and I would like to know how to verify that a specific bit is at 1 or 0.
Pokus's user avatar
  • 11.7k
119 votes
7 answers
147k views

C99 stdint.h header and MS Visual Studio

To my amazement I just discovered that the C99 stdint.h is missing from MS Visual Studio 2003 upwards. I'm sure they have their reasons, but does anyone know where I can download a copy? Without ...
Rob's user avatar
  • 77.9k
17 votes
2 answers
9k views

Making something both a C identifier and a string?

Say you want to generate a matched list of identifiers and strings enum { NAME_ONE, NAME_TWO, NAME_THREE }; myFunction(NAME_ONE, "NAME_ONE"); myFunction(NAME_TWO, "NAME_TWO"); myFunction(NAME_THREE, ...
OJW's user avatar
  • 4,582
35 votes
7 answers
12k views

Checking stack usage at compile time

Is there a way to know and output the stack size needed by a function at compile time in C ? Here is what I would like to know : Let's take some function : void foo(int a) { char c[5]; char *...
shodanex's user avatar
  • 15.2k
58 votes
10 answers
87k views

Capturing stdout from a system() command optimally [duplicate]

I'm trying to start an external application through system() - for example, system("ls"). I would like to capture its output as it happens so I can send it to another function for further processing. ...
SinisterDex's user avatar
14 votes
15 answers
2k views

Should .NET developers *really* be spending time learning C for low-level exposure? [closed]

When Joel Spolsky and Jeff Atwood began the disagreement in their podcast over whether programmers should learn C, regardless of their industry and platform of delivery, it sparkled quite an explosive ...
icelava's user avatar
  • 9,847
8 votes
4 answers
2k views

Lower than low level common bsd sockets

How do you do low low level sockets in C, example: actually sending a SYN.
Brian R. Bondy's user avatar

15 30 50 per page