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

learn more… | top users | synonyms

-3
votes
0answers
23 views

C: How to get address of a pointer? [on hold]

I have a question about pointers: If I have: int *pi = (int*)&array[0][7]; , `char array[10][10]` and for example let array[0][7] be 97 'a'. How to get value and address of this pointer ...
-4
votes
0answers
56 views

What C Language is most beneficial? [on hold]

For the last few years I've been focusing on Web Development (HTML/JavaScript/JQuery/PHP/etc...) and haven't REALLY worked with any variant of C for quite awhile. I'm familiar with C++ from using it ...
0
votes
0answers
36 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
103 views

Has pre-increment operators become that common? [on hold]

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
2answers
158 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 ...
-6
votes
0answers
62 views

Can a c function return an array? [on hold]

Can a C function return an array? If I defined a function, say: int sum(int A[5][5],int B[5][5]) { int z[5][5], i, j; for(i=0; i<5; i++){ for(j=0; j<5; j++){ z[i][j]=A[i][j] + ...
0
votes
2answers
74 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 ...
-4
votes
0answers
26 views

Ok so i have fully done the first part of the q, i am so stuck on the second part, everytime i try it my code just stops working [closed]

Update the car_type structure to store the tax as well computed as above and write the output both on the screen and on a file using file-related functions. Use a user menu. Test the program by ...
0
votes
0answers
60 views

Is there a map already written in C that I can use to map a char* to a struct? [closed]

I need this to be in C, not C++. Is there a map already written that can map a char* to a struct? I know C++ has std::map but unfortunately the rest of my program will not compile if I use this map ...
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 ...
-3
votes
1answer
73 views

How to reverse the nibbles in long long int variable in C? [closed]

I need the help to resolve the below in C code. I have a long long int k=0x0000888804eaad0e and i need the reverse of this (nibble wise) in other long long int variable. that is i want the result to ...
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?
-2
votes
0answers
127 views

alternatives to pointer to function in C [closed]

I have C project where I have something like iterator, works like this: Item *mem_first(MemtableIT *it); Item *mem_next(MemtableIT *it); and Item *disk_first(DisktableIT *it); Item ...
-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
56 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
212 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
84 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
37 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
196 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
55 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 ...
-1
votes
0answers
11 views

Printing calculator- stephen kochan programming in C question [migrated]

I'm a newbie at programming, just one month into C. Working with stephen kochan's programming in C. There is a question in chapter 6 to write a printing calculator where 's' tell the program to set ...
0
votes
1answer
127 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
103 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
95 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
72 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
620 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
91 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
129 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
105 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
145 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
517 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
674 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
83 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
114 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
107 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
227 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
180 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
115 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 ...
0
votes
1answer
121 views

C-library - newbie guide

I have been asked to provide a C-library of my code (which I have written in a high-level language). I will hire a programmer to implement my code in C. I would like a short introduction to what a ...