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

learn more… | top users | synonyms

-9
votes
0answers
55 views

C programming explanation [on hold]

I would like to ask you why part 2 = 2 3 -2 and part 3= 3 3 9. I know the answer of the part 1 please explain. When I compile, I get the answer. But I did not understand the rest of that. #include ...
-4
votes
0answers
40 views

x86 assembly books; but looking for something slightly different [on hold]

Are there Assembly tutorial books that clearly explain the relationships between a high level programming language and the x86 assembly language during compilation ? For example, I know a very good ...
-3
votes
0answers
19 views

Cuda code doesn't seem to Launch the Kernel [closed]

I'm trying to compile the next CUDA code, everything goes well with the command: nvcc -o test.exe test.cu, but the problem is that when I execute the program doesn't seem to launch the kernel ( I ...
5
votes
1answer
138 views

Kth selection routine - Floyd Algorithm 489

I have recently come across a promising Kth selection routine that reportedly outperforms quickselect the Floyd, Rivest Select routine. This Wikipedia article provides a pseudocode version which I ...
0
votes
0answers
21 views

Synchronizing content between web-based app and game server

I have a MUD server, written in C, that I'm trying to move from file-based storage to MongoDB. Eventually, I'd like to offload administration of game content and settings to a web console, written in ...
-2
votes
1answer
49 views

Copying desired bits from variables [closed]

What's the best way to copy desired bits from char, int or any other variables? I want to see all possible and the most efficient techniques for this purpose. I have for example 16bit variable 0000 ...
5
votes
2answers
100 views

What is a reasonable level of detail for a style guide? [closed]

We are developing embedded software for an automotive product in ANSI-C in a large team. Yesterday, in our regular code review, we had a general discussion about the style of our code. We have a ...
-1
votes
0answers
4 views

Reccursive function of the sequence $$U_n=\frac{1}{3} (\frac{A}{U^2_{n-1}} + \frac{1}{U_{n-2}})$$ [migrated]

#include<stdio.h> #include<conio.h> #include<math.h> void triple_root(float B[1000],int i,float A,float b,float c) { float x; x=0.333*((A/(b*b))+(1/c)); ...
-4
votes
0answers
29 views

What is difference between hex and char array print? [migrated]

I have written following programe in c #include <stdio.h> char str[]="hello world"; unsigned char hexvalue[] = {0x01,0x02,0x03,0x04,0x05}; int main() { int i; printf("string %s \n", ...
2
votes
2answers
90 views

What are the benefits of a device driver when I can access the I/O registers directly?

I was interested in what modern, C-based, Linux device driver development looked like, and so I took a good gander at this excellent article. I didn't read every single line, but perused the majority ...
2
votes
0answers
145 views

Embox compilation and flashing [migrated]

I am interested in attempting to compile, package and flash Embox to an MCU, from either a Windows or Mac machine (cross-compilation), via JTAG, and I have a number of concerns. Observe what I ...
2
votes
2answers
71 views

Compiling and deploying a C program to an MCU running an RTOS

Please note: Even though I'm specifically talking about an RTOS called Embox here, and even though I'm talking about AVR/ARm, I think this question can be answered by anybody whose ever done a fair ...
2
votes
1answer
58 views

Compiling and deploying RTOS to an MCU

Please note: Even though I'm specifically talking about an RTOS called Embox here, and even though I'm talking about AVR/ARm, I think this question can be answered by anybody whose ever done a fair ...
3
votes
2answers
97 views

Benefits of RTOS vs Bare Metal for MCU Programming?

Please note: This question specifically mentions two RTOSes but is more generic and can probably be answered by anybody who has written C code for embedded RTOSes before, and had their software run ...
0
votes
0answers
46 views

GMP Core Dump while using mpz_clear in C

I'm working on a prime factorization program written in C using the GMP library through cygwin. The algorithm that I have now works fine, but has memory leaks from not using the mpz_clear function on ...
-1
votes
0answers
26 views

Casting to pointer warning [migrated]

I defined variables display_address, version, serial_no[] as uint8_t and forwarded them to function, that variables need to be pointers so I casted it (uint8_t *)variable, and after that I'm getting a ...
48
votes
8answers
6k views

Why does C provide language 'bindings' where C++ falls short?

I recently was wondering when to use C over C++, and vice versa? Fortunately someone already beat me to it and although it took a while, I was able to digest all the answers and comments to that ...
0
votes
0answers
50 views

Best way to signal all child processes to terminate using C

I have been assigned the task of designing a simple web server using C in my UNIX & C class. The webserver listens and forks when a successful connection is made so that multiple clients may be ...
2
votes
0answers
149 views

Have any C compilers ever *defined* `unsigned short x=-3; x*=x;` to yield anything other than 9

In a C implementation where int can hold all values of type unsigned short, standard integer promotion rules dictate that given the code: unsigned short x=(USHORT_MAX+1)-3; // Or just -3 x*=x; a ...
0
votes
0answers
12 views

c Programming, dynamic allocation + linked lists [migrated]

I am having trouble with this code, and i'm not sure what i'm doing wrong #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> typedef struct ...
-2
votes
1answer
115 views

Question about switch-case statement [closed]

What happens, and does code work properly if we write switch-case structure like this, why its not good to write code like this? I'm porting some firmware and have switch-case statement interrupted ...
1
vote
1answer
78 views

Equivalent translation of Asynchronous behaviour in C

As a follow-up to my other question, if one were to build a general-purpose translator from a language that has support (be it with an external library or otherwise) for asynchronous behaviour to a ...
-3
votes
1answer
69 views

Executable File Size Difference Between Python and C [closed]

Does using lower level programming languages have benefit of generating lesser file size when creating an executable, in contrast to using higher level languages for the same algorithm?
3
votes
1answer
144 views

Implementation of Asynchronous function call in C

I took it upon myself recently to work towards making a general-purpose Translator to automatically translate js programs into C, but I got stuck when thinking of asynchronous behaviour. Using ANSI / ...
6
votes
8answers
700 views

Structuring Procedural vs OO code

I have spent the vast majority of my programming career using Java and very OO based C++. I am really interested in learning to think more procedurally, so I have been starting to do some practice ...
-2
votes
1answer
58 views

how integer type can handle text stream (getchar()) in C? [closed]

While going through C programming by Ritchie and kernighan, I came across the following code. #include<stdio.h> int main() { int t; t = getchar(); while ((t=getchar()) != EOF) { ...
2
votes
2answers
230 views

How does printf write to stdout?

I've been looking for an answer to this for a couple days, and all of the results I've come up with are about how printf accepts an arbitrary number of arguments. How does printf write to stdout? ...
-1
votes
2answers
95 views

In C is it possible to change http requests to https [closed]

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 ...
1
vote
5answers
472 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 ...
17
votes
8answers
964 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 ...
0
votes
0answers
59 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
133 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
220 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
93 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 ...
1
vote
3answers
229 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(); ...
2
votes
2answers
96 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 ...
-3
votes
1answer
51 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
231 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
81 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
136 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 ...
15
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
115 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
141 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
152 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
79 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
84 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
637 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
153 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
166 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
108 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 ...