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
5answers
138 views

Why C language is taught as the basis of Computer Programming Languages? [duplicate]

I often wondered why C Language is taught as the basis of programming languages everywhere. There are a lot of modern languages like Java, Python etc. which makes the syntax and programming easier. ...
-3
votes
1answer
109 views

Why Java is more demanded than C language? [on hold]

I'd greatly appreciate a response on the following question relating to C language. After giving interviews in many companies, I only conclude that C language is only school level programming ...
-2
votes
0answers
17 views

Why do I always get the result File not RIFF? [on hold]

I'm trying to make a wav player without using any libraries just solid C and x86 assembly which is compatible with DOS PC's.I am using Turbo C compiler (version 3.0) pcm and stereo aren't supported in ...
-1
votes
0answers
95 views

Can someone clarify strings for me in the C programming language [migrated]

Hey guys so I'll cut this short. A few weeks ago I started learning the programming language C. I have knowledge in web technologies like HMTL/CSS, Javscript, PHP, and basic server administration. ...
4
votes
3answers
160 views

Safety-critical software and optimising compilers

I'm reading some internal documentation for code developed to the MISRA C guidelines, and I see that in compiler flags section of the documentation there is a note to compile with optimisation off ...
0
votes
0answers
4 views

Linux C raw socket TCP handsake [migrated]

I'm trying to create a TCP connection using raw sockets in C (on a Debian system) but I'm having a hard time getting it working. It will send a packet but I dont get any response from the server. I ...
-4
votes
0answers
31 views

What are some best practices for converting a codebase from Matlab to C using MATLAB Coder? [on hold]

I am starting a project to convert a medium size Matlab codebase (~100 files, total of ~10K LOC) into C/C++. (That is, the end product needs to be runnable without Matlab.) I have been reading ...
3
votes
1answer
47 views

Bottleneck performance in ECS

I've been looking into building an entity-component-system. Basically, an entity is just an id wrapped around a struct, components are data belonging to that entity(and reference said id), and systems ...
12
votes
5answers
2k views

Why is *declaration* of data and functions necessary in C language, when the definition is written at the end of the source code?

Consider the following "C" code: #include<stdio.h> main() { printf("func:%d",Func_i()); } Func_i() { int i=3; return i; } Func_i() is defined at the end of the source code and ...
-1
votes
2answers
232 views

Disadvantages of Pointers [closed]

I was wondering why pointers are not included in modern languages now-a-days. I already did research on this on internet, and found out few theories/reasons: Memory leakage is the biggest concern ...
103
votes
6answers
18k views

Is every language written in C?

Sometimes while programming in different languages, this thought comes to my mind: Is each and every language written in the C programming language? Is the C language the mother/father of all ...
3
votes
2answers
162 views

Why define struct in variable?

Consider the following program: Many people when they want to use a struct, they create a new variable as: struct structureName variableName While it works when you just define it as: ...
-6
votes
0answers
58 views

Replace tabs with spaces in C [closed]

i want to replace tabs with spaces but i didn't get it. I have an file pointer which i give into the function and there are some \t and i want to replace them with as many spaces as needed. For ...
-5
votes
0answers
65 views

C application vs C++ application [closed]

What are a real life application that is based on C language rather than C++? Why is it using C and not C++ since they are almost the same? Do you think we can convert that application to C++? And how ...
-3
votes
1answer
36 views

How can this allocation of bi-dimensional arrays work?

I was seeing this post on StackOverflow and saw a new way (at least for me) to define a two dimensional array of 5x5, it works well, but I feel I don't understand what is going on in the background. ...
-2
votes
0answers
58 views

Is the time complexity of this code snippet O(n)? [migrated]

struct lists * list_depth[ht]; for(int i=0; i<ht; i++) list_depth[i]=NULL; insert_to_list(&list_depth[0], root); for( int i = 1; i < ht; i++ ) { struct lists * temp = ...
-4
votes
0answers
50 views

Custom code folding in Eclipse [on hold]

For those who use Eclipse and are working primarily in Java, there is a custom folding plugin coffee script. It is old but still works. However, C/C++ users are left without code folding ...
-2
votes
0answers
36 views

Find the number of increasing Sequence of length K [closed]

Let we are giving a Array we have to find the number of increasing sequence of length K. 1 2 3 1 1 For the first window of [1, 2, 3], there are 3 non-decreasing subranges so the answer is 3. For ...
1
vote
3answers
125 views

Use of for loop conditional statement unrelated to iterating variable

Is it considered decent form to write code like this: int done = 0; for (x = 0; !done; x++) { ... something involving 'x', that might end early ... if (!(x < max)) done = 1; } ...
1
vote
3answers
73 views

Question about multidimensional arrays

I was wondering something about the multidimensional arrays and then I got a doubt about a concept, specifically about their representation on memory. For example, an array can be defined as follows. ...
1
vote
2answers
209 views

Searching algorithm used in switch statement

What is the searching algorithm used in switch statement in C language? If the cases are not in order still it searches proper case which means it is not a binary search algorithm, can anybody ...
0
votes
1answer
106 views

Introducing function waypoints to protect device [closed]

Defining a magic pointer or counter inside a program / class and checking for a fixed value before executing critical commands is a way to generate a barrier against wrong execution. This check is ...
-2
votes
1answer
82 views

Printing value of atoi of an array - what does the number mean? [closed]

Simple question, below is my code. The number my compiler returns is 4219296. My question is: why? What is my code doing here? #include <stdio.h> int array[]; int main() { atoi(array); ...
17
votes
3answers
1k views

Why do we have to mention the data type of the variable in C

Usually in C, we have to tell the computer the type of data in variable declaration. E.g. in the following program, I want to print the sum of two floating point numbers X and Y. ...
0
votes
0answers
17 views

Is `\n` necessary to be given to `printf()` in C [migrated]

I am reading the book "The C Programming Language" by Brian Kernighan and Dennis Ritchie. In the first article they say that one must use \n in the printf() argument, otherwise the C compile will ...
-2
votes
0answers
24 views

C - meaning of non zero adresses in nullspace [migrated]

This is a linked list queue implementation. This is my program int size(QueuePtr q) { QueuePtr temp = q->next; int size = 0; while(temp) { size++; temp ...
0
votes
0answers
6 views

Matrix Multiplication question [migrated]

So I'm trying to write a C function to calculate the multiplication of two arrays but I am a little bit stuck. double ** matrixMultiply(double **A, int nRowsOfA, int nColsOfA, double **B, int ...
0
votes
0answers
5 views

Loop in system call C program [migrated]

I want to call the function wget in a loop in ubuntu, how can I do it? This is what I did, but it didn't work. for (i = 1; i < 500; ++i) { system("wget -O page%i 'http://www.asdf.com/?=%i'", ...
3
votes
4answers
330 views

Why do we have to tell printf() the type of data in C?

Let's consider this C code: #include <stdio.h> main() { int x=5; printf("x is "); printf("%d",5); } In this, when we wrote int x=5; we told the computer that x is an integer. The ...
-1
votes
0answers
22 views

Get defines dynamically for messages [migrated]

In this following code, i want to use predefined message for my errors_manager function, with the macro CALL_MSG(). but when i use an variable, i can't get the content of the variable ! err = ILLOPS ...
-2
votes
2answers
69 views

Using a global struct with pthreads in C [closed]

I'm trying to simulate clients going into a bank and being served by tellers over a period of time. I am using a thread to determine if a client came into the bank via an arrival rate and am using ...
-5
votes
3answers
79 views

Some tips on creating programs in C? [closed]

So I'm currently in my first year in university studying electrical engineering. I'm taking a intro to C course, and I'll say it now, I'm not sure if I'm going to be able to pass the exam. Even with ...
2
votes
1answer
115 views

Exceptions in ANSI C

Would it be possible to implement exception mechanism in pure ANSI C similar to the one used in popular OOP languages (with familiar try-catch-finally clauses)? If yes then how? I'm especially ...
0
votes
0answers
40 views

type name for state machine state (as opposed to other state variables)

I need to create a typedef for a state machine state, e.g. enum ToasterStateMachineState { TSM_READY, TSM_TOASTING, TSM_DONE }; But ToasterStateMachineState seems verbose and redundant; is ...
4
votes
1answer
109 views

What is grouping?

In the introduction to K&R there is the following text: Similarly, C offers only straightforward, single-thread control flow: tests, loops, grouping, and subprograms, but not ...
0
votes
3answers
140 views

Socket Connecting to Large number of IPs

I have a text file of ~600 CIDR notation IP blocks which, when expanded, amount to ~17.5M IP addresses. I need to socket connect to each one. If it connects, I add it to a "live" list, if it returns ...
0
votes
0answers
57 views

Does multiple Bloom filters make sense?

In order to decrease the number of false positives, I came up with a couple of possible solutions. Create two different types of Bloom filters; eg. filter1 using 3 different hash algorithms, filter2 ...
-1
votes
1answer
65 views

How implement a doubly linked list using single pointer inside? [closed]

struct{ int value; int *pointer; } I want to make doubly linked list using the above structure.
1
vote
3answers
234 views

Including extra headers that I do not really need

I always wondered what are the effects of including not needed headers to the final executable once compiled. In my code some times I may included many different headers that I do not need (or I used ...
2
votes
1answer
201 views

Quickest sorting algorithm for sorting a low number of integers

I am making a program on my spare time that I want to run as quickly as possible. The program is written in C. A large set of the procedures operate on pointers to 7 integers that are sorted by their ...
24
votes
7answers
2k views

Is it good practice to rely on headers being included transitively?

I'm cleaning up the includes in a C++ project I'm working on, and I keep wondering whether or not I should explicitly include all headers used directly in a particular file, or whether I should only ...
1
vote
1answer
73 views

Holding of files being edited in a text editor

I'm writing an implementation of Ex (hopefully Vi eventually) as a personal project. I need to somehow store an identifier for the file associated with each buffer. In terms of security/race ...
0
votes
0answers
84 views

In-place merging of sorted intervals in an array?

So I have code producing k sorted intervals in an n-sized array. What I'm brainstorming is the possibility of in-place merge of these intervals into a single sorted interval/array. The problem is ...
4
votes
2answers
164 views

When should a trig function, with a degree argument, return -0.0?

In creating trig functions my_sind(d), my_cosd(d), my_tand(d), that used a degree argument rather than a radian one and provided exact answers at multiples of 90, I noticed that the result was ...
0
votes
3answers
123 views

Alternative to printing debug information to stdout\stderr [duplicate]

I currently have a long running application on an embedded Linux environment and all debug messages are currently being outputted to stdout using printf. This isn't ideal for special users who ...
6
votes
1answer
209 views

Do any notable C extensions include integer types that are independent of machine word size

An interesting characteristic of C compared with some other languages is that many of its data types are based upon the word size of the target architecture, rather than being specified in absolute ...
1
vote
2answers
365 views

Generics in low level languages

I'm developing a language like Vala and OOC that compiles back to C. This means that, eventually, every feature needs to be adoptable to C code in some way or another. Generics is one of the features ...
7
votes
2answers
208 views

Autoreleasing objects in Reference Counting Systems

I'm experimenting a bit in C and I'm trying to implement my own Reference Counting System. I've mainly worked with Objective-C in the past but AFAIK autoreleasing objects is something that is unique ...
1
vote
0answers
65 views

Is conversion from C/C++ to Verilog/VHDL for FPGA a derivative work? [duplicate]

Say I have a C/C++ software licensed under GPL that gets converted into hardware design. By this conversion I mean that the exact functionality of the original software is being programmed into an ...
3
votes
6answers
245 views

Explicitly define enum values, even if the default value is the same?

There are times when an enum's values are important: it is not necessary for them to be unique, they also need to have specific values. In such cases, should the values be explicitly defined, even if ...