C is a general-purpose computer programming language used for operating systems, games and other high performance work.

learn more… | top users | synonyms

0
votes
1answer
39 views

In C is it possible to change http requests to https

Long story short I've got this package that currently has a security risk where credentials are sent over http and I need to convert them to https but I currently lack the knowledge to do so. Could ...
-3
votes
0answers
24 views

Text UI strategy game: Which Language/engines? [on hold]

I'm thinking about building a simple 2d strategy game, the likeness of starcraft, except extremely simplified. The main thing I want to do is have a text UI, the kind of thing you see when you ...
-2
votes
0answers
84 views

What will happen if I execute this code?

I study multicore and I have this problem. Assume that prior to executing the code below, a=1 and flag=0. CPU0’s code a = 2; flag = 1; CPU1’s code while (flag != 1) ; // Wait until flag is 1 ...
-1
votes
0answers
32 views

int differers in level of indirection from char error [migrated]

The code is from Absolute beginner's guide to C, and I get this error ./BlackJack.c<41> : warning C4047: '==' : 'int' differes in levels of indirection from 'char [2]' when I try to compile it ...
-2
votes
0answers
136 views

Why do C based languages use a colon for the case's? [on hold]

Why is a colon used at all? For example: switch( c ) { case 'A': CapitalA++; case 'a': SmallA++; default : total++; } Instead of: switch (c) case 'A' ...
1
vote
5answers
315 views

How to share memory between applications written in C/C++

I'm going through a program written in C/C++ for control in robotics. Basically, three different programs run at the same time, and they communicate via shared memory. Google-ling around I found ...
16
votes
8answers
824 views

Is directly using Make considered obsolete?

So I have been coming across many comments/posts/etc regarding creating makefiles directly, and how it is a silly thing to do in 2015. I am aware of tools such as CMake, and I actually use CMake quite ...
-5
votes
0answers
40 views

How to generate strings from regular expression in C or Python? [closed]

I am beginner for programmer for theory of computation problems. I am looking for solution for which will generate strings from the regular expression in C or in Python. example I am looking for the ...
0
votes
0answers
120 views

Why does this execute a jump instruction? [migrated]

I have just seen a very interesting C code in the boot loader of a small embedded product. The code consists of two parts: boot loader and the main code. The start of the main code address is stored ...
0
votes
0answers
44 views

Abstract Web API from validation and configuration management in embedded system

Im working with embedded Linux for a router. There is a web GUI for the user to configure router options. When user fill a web form this is submitted to a web server function that is responsible of ...
0
votes
1answer
120 views

Has pre-increment operators become that common? [closed]

Bit of background to explain the reasoning: I've been programming for a good while, but took a break between 2012 and 2014 for other stuff. Before that break, I would hardly ever hear about "++i", let ...
2
votes
1answer
200 views

How can C++ make it possible to use dynamic container classes even in embedded systems?

How can C++ make it possible to use dynamic container classes even in embedded systems? Background info: I've been working with PIC (C) and AVR (C++) processors and at the moment (PIC C) I'm ...
0
votes
2answers
83 views

Idiomatic C API with regards to pointers

I am trying to get a better understanding of how one would structure an API in C. I create a struct Person I have a init function that sets data on that struct I have multiple "helper" functions ...
0
votes
0answers
14 views

Threads to print numbers sequencially : with even and odd threads running parallely [migrated]

I am new to multithread programming. I tried to print numbers sequentially using even and odd number printing threads, running in parallel. When executed, the code enters a deadlock. Can anyone help ...
1
vote
0answers
72 views

GNU Simulated Annealing [migrated]

I'm working from the template program given here: https://www.gnu.org/software/gsl/manual/html_node/Trivial-example.html The program as they give it compiles and runs perfectly, which is nice. What ...
0
votes
0answers
3 views

protobuf-c message over poll() read [migrated]

protobuf-C packs uint8_t chars and I am trying to unpack them from a poll recv() command. Is this a compatible format recv(int sockfd, void *buf, size_t len, int flags) call?
-1
votes
0answers
18 views

Closing Nonduplex Unnamed Pipes in C [migrated]

I have 8 children, and am trying to use 8 pairs of nonduplex unnamed pipes to communicate with them. Thus, I have 2 pipes for each child and 16 pipes in total (one for childRead_ParentWrite and the ...
1
vote
0answers
62 views

Use of SAL annotations for C++ [closed]

Code analysis tool for visual studio is able to detect some kinds of errors statically if you annotate functions with SAL We used it at first in windows driver when code was mostly C code, and where ...
-1
votes
0answers
16 views

How to pause for a second in a C program? [migrated]

I'm creating a simple C program which prints to the console and I want to have the program pause between printing, to create an aesthetic "..." slow printing effect, to make it appear as if it is ...
1
vote
3answers
216 views

Alternative to goto-statement in this case? [duplicate]

Currently I am using gotos for closing handles and general cleanup if an error occurs. Since I don't want to nest all the ifs and a function for cleanup would require a return besides the cleanup(); ...
0
votes
1answer
43 views

Printing an geomterical object/structure and determining the mid point of the two lines passing through it

I am very basic in C programming, may be printing a variable or so. Can any one of you can help me to give me a example code or guide me how to construct an object and determine its mid point? Or to ...
-1
votes
0answers
14 views

Difference between (int*) calloc and just calloc? [migrated]

What is the difference between: int *array; array = (int*) calloc(5, sizeof(int)); and int *array; array = calloc(5, sizeof(int)); I don't get it. Both samples work. At the university the ...
2
votes
2answers
88 views

Function naming design in a C Library

I'm writing a C (c99) library that operates on strings. I'm having a design problem writing functions that will perform in different modes. For example; the Find function can search for: the ...
0
votes
0answers
4 views

C error: parameter has incomplete type [migrated]

I am a relatively new C programmer, so please bear with my ignorance :-) I am trying to get a custom tool for valgrind to compile. The tool was originally written about 8 years ago, and was based on a ...
-3
votes
1answer
40 views

Passing Parameters to pthread_create [closed]

I have a structure named graph. graph *G; Now I create memory of size of structure using malloc and the start pointer is stored in pointer G. G = (graph*)malloc(sizeof(graph)); My question is ...
4
votes
1answer
204 views

Should I always return an error code from C functions?

I have the following code in many places in a large application: if (datastruct.data_ok && cur_time > datastruct.start_time && cur_time < datastruct.end_time) { ...
0
votes
0answers
58 views

Writing Z80 table based assembler/disassembler

I have a long-term project: DIY computer with various processors. One of my wishes not only make hardware, but software too. So I started from assembler/disassembler for Linux, though there is a lot ...
0
votes
1answer
132 views

Can i create a function with variable parameters in C?

I've always wondered where a single function such as printf(); can take in variable parameters and provide the right results. For example, printf("Number is %d",a); which has two parameters, and ...
16
votes
9answers
3k views

Can you “stop” a C program from being reverse engineered? [duplicate]

I'm sure that many of the middle to high level languages can be reverse engineered. But if a C program can be reverse-engineered, and turned back into editable source code, how do I discourage such a ...
1
vote
3answers
104 views

Will C compiler attach the whole object code of the header file?

When you compile a C source code does the compiler convert the whole header file to object code or just the functions of the header file you use? Like for example, in the header file #include ...
1
vote
2answers
131 views

In C, what is an unconditional jump?

I have to fill out some documentation regarding a C project i worked on. One topic is whether I used "unconditional jumps". As far as I know, a "break" statement counts as a jump. And I have a few of ...
2
votes
2answers
101 views

Returning multiple values from a c function using pointers; style of parameter list

What is good programming style for writing C-language functions and function calls to functions which return pointers? For example, if I have a function my_function which return two integers through ...
1
vote
0answers
75 views

How to use an enumeration type, when the values are not known at first?

We have a project, that consists of a cluster of C source code, a C library and a C++ library. The C++ library is dependent only upon the C library, or at least that is what I am trying to achieve. ...
0
votes
2answers
82 views

forking but not exiting

It is normal for the child in a fork() to call exec() or _exit(). Are there any realistic scenarios where the child might return from the function that called fork() instead? void foo() { pid_t ...
11
votes
2answers
622 views

Java has the JVM, what does C have?

I know that C has a compiler but what determines execution performance? For example in an if else block, what if the code just had all ifs instead of if elses, what determines that all the ifs will ...
2
votes
2answers
100 views

Should I use multiple state machines for a layered protocol?

When implementing a layered communications protocol are layers commonly implemented as state machines? I have an implementation of PMBus I am currently working on for an embedded device. I have a ...
-1
votes
3answers
134 views

is it possible to make a gui in c without an external library [closed]

I was wondering if it is possible to make a gui application in c without the use of an external library (like gtk+ or wxWidgets). And if it not possible without the use of an external library, how ...
0
votes
2answers
106 views

Trouble understanding simple recursion in c [duplicate]

My function: int num(int x) { if(x>0) num(x-1); else return 0; printf("%d",x); } This function takes a input x and prints the numbers from 1 upto x.I can't seem to ...
-3
votes
2answers
151 views

Can a high level language be faster than native C? [closed]

Hand-crafted C is almost unbeatable. If an experienced C developer knows what he is doing, he will be able to write C code much faster than higher level code. But can a medium/big programme written in ...
55
votes
5answers
11k views

Why are there so few C compilers?

C is one of the most widely-used languages in the world. It accounts for a huge proportion of existing code and continues to be used for a vast amount of new code. It's beloved by its users, it's so ...
0
votes
5answers
522 views

Is a makefile really needed

I have been programming in c/c++ for a while now, and I have never once used a makefile. I know that it is supposed to be useful when you are dealing with a large project, but I have always been able ...
3
votes
2answers
687 views

How do you usually compile C/C++ source code ? (Large code bases) [closed]

It's been quite some times since I began learning C and C++ but I've been very limited only to the Windows platform and the Visual Studio environment. Recently, I wanted to look into some open source ...
-1
votes
1answer
85 views

Understanding the solution of exercise 1.16 of K&R as given in the “The C Answer book”

The exercise 1.16 in K&R's book asks, Revise the main routine of the longest-line program so it will correctly print the length of arbitrary long input lines, and as much as possible of ...
-1
votes
1answer
129 views

How static functions are better than Class Methods in Objective-C [closed]

I was going to through this post by Mattt Thompson in which he mentions that Static functions are nicer than shoe-horned class methods I just don't see any flaw with Class methods in ...
0
votes
2answers
108 views

Organizing C++ Components [closed]

In my current company we've brought the discussion about how to organize most of our different C++ components considering the following requirements: There might be interdependencies between ...
0
votes
1answer
229 views

Understanding the solution of Exercise 1.12 of K&R's book as given in the book “The C Answer Book”

I am reading the solution of "The C Answer Book". I think that the solution of Ex. 1.12 can be shortened. The Exercise is as, Write a program that prints its input one word per line. The ...
0
votes
3answers
47 views

Data inter-exchange with C

I'm developing a system in which a C coded TCP server is listening for new connections from clients, on connection parse the data & store into database. I'm familiar with JSON, and would like to ...
2
votes
1answer
182 views

An embedded C developer wishing to interface some code with a web page

Okay, so as the title says, I'm an embedded C/C++ developer. Right now, I'm working on a project that involves a client/server C application. The server side of the application is running on ...
2
votes
1answer
120 views

Functions returning strings, good style?

In my C programs I often need a way to make a string representation of my ADTs. Even if I don't need to print the string to screen in any way, it is neat to have such method for debugging. So this ...
2
votes
2answers
182 views

Place variables frequently used by the same function on the heap?

Say that I have the following situation: void myFunc() { int x; //Do something with x } "x" is placed on the stack which is no doubt fast. Now, "myFunc" is called very frequently, lets say ...