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
55 views

Looking for a certain datatype if it exists

I'm looking for the kind of a certain datatypes. The main idea of this datatype is to describe a productionline containing several steps. Each step should be represented as a "vertex" containing an ...
-2
votes
0answers
36 views

Cricket Score Board in C [on hold]

I was Coding for my final project submission and there is error that the individual player's score doesn't add up according to the input, have a look and please correct me if I'm in the wrong section. ...
0
votes
5answers
78 views

What conclusion to be drawn from no difference in generated assembly from 2 rather different programs?

I might not have had a counterexample when I got the reply "A pointer is just an address, what's the difficulty?" but I didn't really buy such a simple explanation and at assembly code it's not ...
3
votes
2answers
183 views

Are (C) object files created with different compilers binary-compatible?

I understand that C++ compilers are not compatible with each other. However, I was unable to find anything on this topic for C in particular. I know that the C standard leaves a lot of room for ...
-1
votes
0answers
97 views

Is there a difference between writing/passing value with or without float “f” suffix? [migrated]

I believe I should type less if it's possible. Any unnecessary keystroke takes a bit a time. In the context of objective-C, my question is: Can I type this [UIColor colorWithRed:0 green:0 blue:0 ...
-1
votes
0answers
19 views

ALSA programming in C - `snd_ctl_card_info ()` issues [closed]

I'm trying to write a simple C program to list available ALSA sound cards on Linux. My problem is with a simple printf () statement I'm using for a little debugging. Here's the section of code ...
-2
votes
0answers
24 views

How do I read the content of a file by using filename as argument to function main? [closed]

if I have a file and I can take it as my standard input by using fget and a loop to read all the characters inside the file. My question is How do I read the content of a file by using filename as ...
0
votes
0answers
74 views

Adding Very Large Array's in C. Is there a better way to do this? [migrated]

I am writing a stochastic simulation for a yule process. It basically works likes this if you start with a certain number of bins each containing a random number of balls you add another ball to an ...
-3
votes
0answers
48 views

Sqrt function working in c [closed]

How does sqrt function really work ? Does it go by any logical theorem to get the result. Is there any way i can access the code of libarary function such as sqrt?
-1
votes
0answers
32 views

Basic C programming [migrated]

I'm trying to write a program which given a certain number of input will output the product of the listed input (only accounting inputs of 0-9 and ignoring other). For example: input:345 would result ...
0
votes
0answers
48 views

What concept is being exhibited in this macro wrapping? [migrated]

A bunch of code just got handed over to me and I got baffled by macros in the header. I could not understand what they are for: #define WRAPPER_MACRO(symbol) symbol #define ANOTHER_SYMBOL ...
-4
votes
0answers
52 views

Can I get right guidance to enter software development? [closed]

I am beginner in software development As a beginner I know C/C++ not at expertise level But I am liking Python Give me right guidance
0
votes
0answers
3 views

Creating multiple child processes in C for one parent [migrated]

Everyone! So I've been working on code for my OS class, and in my project, I have to create a new child process for each file on the command line, and pipe information from the child to the parent. ...
0
votes
1answer
63 views

Algorithm for base-conversion in C?

I put in this code which does what it's supposed to do, but perhaps there is a better or more general approach? I'm converting a 4-digit base 10 number e.g. "11" to base 16 e.g. "17" (which gets ...
0
votes
0answers
2 views

putting file-scope variables inside a struct? What is the benefit [migrated]

As a C developer I always used to place file-scope variables as their own variable. static char myChar; static char *myCharPtr; Now I've started people seeing to be placing these variables inside a ...
0
votes
1answer
76 views

How can I handle this string concatenation in C in a reusable way

I've been writing a small C application that operates on files, and I've found that I have been copy+pasting this code around my functions: char fullpath[PATH_MAX]; fullpath[0] = '\0'; ...
2
votes
2answers
166 views

Representing a deck of cards in C (not C++)

So far my best ideas have been as fallows A) Represent a "card" in one structure and have a "deck" in another a deck being an array of 52 cards and a card being 2 chars one for and rank one for suit. ...
1
vote
4answers
214 views

How do you call one program from another?

What I'm wondering is how running programs communicate with each other, and if someone could post some sample code for how to do this, so I can try it out myself, just for educational purposes. For ...
0
votes
0answers
5 views

How to write the mexFunction of this c file [migrated]

The function is cyclic.c. void cyclic(float a[], float b[], float c[], float alpha, float beta, float r[], float x[], unsigned long n) // Solves for a vector x[1..n] the “cyclic” set of ...
1
vote
0answers
65 views

What is the underlying mechanism behind va_list and where is it defined?

http://www.cplusplus.com/reference/cstdarg/va_list/ According to the above link, va_list is an argument or parameter used in some macros - va_start, va_arg, va_end. These macros are present in the ...
0
votes
1answer
151 views

What is this programming style? “Monoid-ic”?

In a moderately old blog post, Conal Elliot makes an interesting (if less than serious) argument that C is a purely functional language, by drawing a parallel between the combination of the C ...
0
votes
0answers
4 views

C Programming help - providing user with option to exit a program [migrated]

I've written a program to compute the running sum of any numbers input by a user. I need to provide the user with an option to exit the program at any stage, which I'm not sure how to do. I was ...
1
vote
0answers
88 views

How to extract the active code path from a complex algorithm

I have been puzzled lately by an intruiging idea. I wonder if there is a (known) method to extract the executed source code from a large complex algorithm. I will try to elaborate this question: ...
1
vote
1answer
82 views

Global variable vs. local-static variable for storing state

I am writing an application for my graduation coursework, in C, using GTK+ UI library. Sometimes I ask for user input, which I need to save for later use. The doubt comes on how to store this data. I ...
0
votes
2answers
169 views

Shared source file between two parts of project [closed]

I have the following sort of directory structure: part1 build src part2 build src Now I have a header file that I would like to include in both parts of these projects, it will ...
3
votes
2answers
219 views

Speed difference between VM-based and compiled code [closed]

Not so long ago I was told by a senior academic that, these days, VM-based code could run nearly as fast as compiled code, but my own experience is that compiled code runs several orders of time ...
1
vote
2answers
201 views

Creation of an Assembler [closed]

I've always been interested in how programming languages are created, so for the past 8 months I've been researching, practicing and more about the creation of compilers. I've been able to quite ...
1
vote
0answers
90 views

Problem with Vi editor using PuTTy [closed]

For my computer science class for intro to c/c++ we are using the PuTTy client to work with Vi. During one of my assignments I was in the other room and apparently my cat jumped up on my laptop and ...
4
votes
3answers
293 views

How to teach pointers to beginners in C? [closed]

I'll hold a little presentation about C-Pointers in a small group of people with beginners programming skills, with no CS background. Just people who would like to learn something about coding and ...
2
votes
1answer
134 views

OOP in C: which of these two approaches is closer to a cannonical solution? [closed]

Here are the two approaches to writing OOP (as in "we have objects and we can instantiate any number of them, each having it's own private data"). The language is C and the platform is embedded ...
3
votes
3answers
183 views

How do I maintain consistency between hard-coded values in different files?

I have a C source file and another (non-code) file in a project which contain the same hard-coded value. Ideally, the value would be specified in only one location and be copied to the other location ...
1
vote
2answers
206 views

Choice between 1-dimensional and 2-dimensional array

I'm implementing the Chessboard class to represent the chessboard. I've to implement the transformations (reflections and rotations) on the chess board possible. The possible transformations includes ...
9
votes
5answers
331 views

How to make it obvious that a function is being accessed from the outside?

This is a C specific question. I am trying to keep everything possible inside the translation unit boundaries, exposing only a few functions through the .h file. That is, I am giving static linkage to ...
0
votes
2answers
74 views

Should functions be prepared for overlapping buffers?

So I have a function in C like this: void crunch(const char *in, char *out, size_t inLen, size_t outLen) { //... } If the two buffers overlap, the function may mess up the input buffer as well, ...
0
votes
1answer
100 views

Is TCP message order still guaranteed when using async IO

Here the scenario I'm imagining. Two messages are transferred, both will require 2 packets each (I know you don't deal with packets directly with TCP, but on the IP level each message will consist of ...
0
votes
2answers
181 views

How do we go from assembly to machine code(code generation) [closed]

I know this is abstract as it's all about signals and switch - (electronics) - underneath, but is there a easy way to visualize the step between assembling code to machine code. For example if you ...
0
votes
3answers
143 views

ANSI C pointers corrupted values

I am working on ANSI C and having some issues with the pointers. That is that after a point in my program the pointer's values change without me interfering, is something like overwriting them. I ...
1
vote
1answer
185 views

Next power of 2 for a number (in search for better “bit-twiddling” way)

I just wonder if there exists better (i.e. faster?) way to get the next power of 2 for a given number than the following one (maybe some better sort of "bit-twiddling" hack is possible?) ... static ...
1
vote
3answers
103 views

C API in C++ with RAII, two alternatives to implement error handling (Exceptions)

I have an API written in C, which produces a result by returning a pointer to allocated memory. For using it with C++ (C++11) I've wrapped the function calls in objects, which keep the result in a ...
0
votes
6answers
487 views

Coming from high-level to C [closed]

I have a web background that grants me basic understanding over programming. Some older kids wouldn't even call that programming knowledge ("any moron can do PHP/Python/Ruby"), I guess, but let's not ...
1
vote
1answer
159 views

Is learning different programming languages from different categories good? [closed]

I have read some posts regarding learning different programming languages or not. Most of the answers indicate that learning more than one programming language increase our horizon as a programmer and ...
-1
votes
1answer
63 views

Creating a window to draw pixels in [closed]

I'm creating a fictional architecture and other fictional components for this computer/emulator. I'm facing an issue, this being the virtual display. I need to be able to create a Window in which my ...
3
votes
1answer
103 views

How can Lisp produce an iterative process from a recursive procedure?

I am starting to learn Lisp, using the SICP book. The authors mention that a procedure (i.e. function) can be recursive or iterative. Additionally, the process those procedures will generate will also ...
2
votes
1answer
94 views

Is the result of strcmp the same on all machines and compilers?

Code: #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n = strcmp("hello","help"); printf("%d\n", n ) ; return 0; } Result: -1 Does ...
0
votes
0answers
41 views

wrap mysql API for gui use

Some time ago now, I've written a command-line tool, that connects to MySQL, and through a series of commands, does all sorts of good stuff. It was originally intended to be used by myself and, ...
2
votes
2answers
161 views

using unsigned integers in c, c++

I have a very simple question that baffles me for a long time. I am dealing with networks and databases so a lot of data I am dealing with are 32-bit and 64-bit counters (unsigned), 32-bit and 64-bit ...
0
votes
2answers
116 views

What are and how do (data-) types work?

What is a "variable"/data type? How does a compiler / interpreter handle types? My specific concern has to do with the different types in lower and higher level languages. For instance in Python, ...
0
votes
1answer
129 views

distributed computing with remote hetrogenous machines

The way i am doing it now is using boost::asio TCP sockets handling everything manually with a main server that orchestrates the processes between the available machines, but the number of machines ...
-1
votes
1answer
80 views

A Server sending data to be processed to clients [closed]

About a year ago I had an idea in mind which was using my friends computers to help me process my data, so I programmed a socket server application with boost::asio, and gave the client part of it to ...
1
vote
3answers
122 views

Question about moving to embedded systems [closed]

I currently work as a .net developer and have coming up to 3 years experience in the industry as well as a degree in computer science specifically software engineering (I know that means nothing but ...