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
0answers
19 views

Why NOP/few extra lines of code/optimization of pointer aliasing helps? [Fujitsu MB90F543 MCU C code]

I am trying to fix an bug found in a mature program for Fujitsu MB90F543. The program works for nearly 10 years so far, but it was discovered, that under some special circumstances it fails to do two ...
-1
votes
1answer
48 views

How to create user defined conditional statements in c?

I have two stacks s1 and s2 with numbers stored in them. I have a function(say comp) which compares the numerical values of s1 and s2. I want to know if it is possible to modify the function so that ...
0
votes
0answers
3 views

Initializing a pointer in struct in at minimum lines [migrated]

I'm currently new to C programming, and appreciate for any tip. Is there a shorter way to initialize struct pointers in C without removing the pointer tags? Thanks~ typedef struct { int x, y, z; ...
-4
votes
0answers
44 views

Receiving udp packets from two remote machines [on hold]

The setting is as follow : i am listening (as machine 1) to two remote machines ( 2 and 3) using 'recvfrom()' (C socket API), i get a message from machine 2 then i delegate to machine 3, machine 3 and ...
-4
votes
0answers
27 views

I need Help making a flowchart [on hold]

I have never made a flowchart before and have no experiance of it. I know what standard symbols and their meaning but I need some examples. If anyone can convert the following code in flowchart form ...
7
votes
5answers
2k views

To integrate git versions as build numbers or not?

A colleague and I have been taking turns debating/discussing the issues/merits of integrating a version derived from the current git repository into our code whenever it builds. We think the merits ...
-4
votes
0answers
35 views

I want to switch my programming platform [on hold]

I have worked as a ASP.NET developer(Web) for 4 years and I waked on Desktop applications as well(WPF). As everyone knows many things are taken care by .net framework and by Visual Studios, as days ...
0
votes
3answers
118 views

Understanding the concept of “arguments” and “parameters” in C language as explained in K&R The C Programming Language

In the third last paragraph at page number 26 of the ebook "The C Programming Language" the author(s) say, "We will generally use parameter for a variable named in the parenthesized list in a ...
23
votes
8answers
10k views

Why was Scala not implemented with C or C++

Does anybody know why was Scala implemented in Java and .NET instead of C or C++? Most languages are implemented with Cor C++ [i.e Erlang, Python, PHP, Ruby, Perl]. What are the advantages for Scala ...
-3
votes
0answers
32 views

The C Programming Language (C&R) ex1-20 . I encounter some trouble [migrated]

/* * 1-20. Write a program detab that replaces tabs in the input with the proper number * of blanks to space to the next tab stop. Assume a fixed set of tab stops, say every n columns. * Should n ...
1
vote
0answers
10 views

Unexpected snprintf behaviour [migrated]

I noticied a (to my opinion) very strange behaviour of snprintf on several platforms. Consider the following code (minimum working example which causes the observed behaviour): #include ...
-4
votes
0answers
55 views

How to fix segmentation fault? [closed]

The following is a function in my C program. When I debug the program using gdb, it is said that there is segmentation fault in the function. But I don't know where is the problem. This function is ...
-1
votes
0answers
57 views

The proper use of continue [closed]

i just want to ask a simple question. i have a doubt that how a continue statement works means that if i use it in a loop. and i know that If the continue statement is inside nested structures, it ...
3
votes
3answers
82 views

sorting / merging hashtable

For my project I have a hashtable with 1M buckets (sometimes more). Each bucket contains lots of values and they are stored sorted in a dynamic array. I am looking for easy enough way to store all ...
0
votes
1answer
161 views

Exercise in 1.6 C by Kernighan and Ritchie

I'm using this book by Kernighan and Ritchie, on the chapter about character input and output and file copying, I'm totally lost as to what this chapter is talking about. This question may seem too ...
116
votes
19answers
89k views

Is there any reason to use C++ instead of C, Perl, Python, etc.? [closed]

As a Linux (server side) developer, I don't know where and why should I use C++. When I'm going for performance, the first and last choice is C. When "performance" isn't the main issue, programming ...
1
vote
2answers
438 views

Is there a better way to organize my module tests that avoids an explosion of new source files?

I've got a neat (so I thought) way of having each of my modules produce a unit-test executable if compiled with the -DTESTMODULE flag. This flag guards a main() function that can access all static ...
0
votes
2answers
195 views

What kind of applications are built using C [closed]

I studied C programming about ten years ago, whiles in Uni,however I would like to pick it up again. I'm looking at developing secure applications that utilize cryptography. Would C be the right ...
3
votes
4answers
250 views

int * vs int [N] vs int (*)[N] in functions parameters. Which one do you think is better?

When programming in C (or C++) there are three different ways to specify the parameter in a function that takes an array. Here is an example (implementing std::accumulate from C++ in C) that shows ...
4
votes
1answer
128 views

Using macros to protect assignment to global variables

Because there is no language feature in C to protect assignment to global variables would you recommend doing something like this? Take this example: We have a module with the header file called ...
-1
votes
0answers
14 views

program in c with strings [migrated]

i have a problem with this code i need to scan strings till i give the char 0 and count how many words with 1 char,2,3... etc here is my code : it never stops include include int main() { ...
16
votes
4answers
2k 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. ...
1
vote
1answer
128 views

How to represent “class” data type in C or any low level language? [closed]

I'm writing a simple language compiler,currently it's support functional programming only. I want to support OOP concept, but I don't know how exactly I can represent an object ? just where to start ...
0
votes
2answers
115 views

How much does C help you in other languages? [duplicate]

How much does learning C to moderate level help you as a programmer. For example, does being competent in C make it easier to pick up languages as time goes on and get a better understanding of them?
0
votes
0answers
10 views

Problem with #include<graphics.h> [migrated]

I am trying to compile a program which includes the graphics.h header file for C. I have added the graphics.h and winbgim.h header files in the include folder and also libbgi.a to lib folder. Just ...
-2
votes
0answers
17 views

Please tell me where I've gone wrong [migrated]

#include <stdio.h> main() { char name1[15],name2[15],name3[15]; int no; printf("Enter the serial number and name one\n"); scanf("%d %15c',&no, name1"); printf("%d %15s\n\n",no,name1); ...
36
votes
6answers
7k views

Why are there no package management systems for C and C++? [closed]

There are some programming languages for which exist their own package management systems: CTAN for TeX CPAN for Perl Pip & Eggs for Python Maven for Java cabal for Haskell Gems for Ruby Is ...
3
votes
2answers
187 views

Is it always safe to shift bool values?

I stumbled about a Cppcheck warning (an inconclusive one), that I mistakenly used & instead of &&: /// @param code identifies the command. Only the lower 16 bits of are being processed ...
24
votes
10answers
9k views

Why are pointers not recommended when coding with C++

I read from somewhere that when using C++ it is recommended not to use pointers. Why is pointers such a bad idea when you are using C++. For C programmers that are used to using pointers, what is the ...
0
votes
1answer
127 views

(almost) Pure C instead of C preprocessor [closed]

Why isn't (almost) pure C used instead of the C preprocessor? Sure I understand it would be a little more verbose. For example: #define PI 3.14159 If we had regular C as preprocessor language, the ...
10
votes
4answers
848 views

Good Programming Competitions for Highschool Students [closed]

What are good programming competitions (or web design competitions) available for highschool students in the Northeast (I am looking for a pretty long/comprehensive list)- of the USA? The competitions ...
11
votes
4answers
1k views

If you favor “T *var”, do you ever write “T*”? [duplicate]

Possible Duplicate: int* i; or int *i; or int * i; Thinking about where we place our asterisks; how do those that prefer to keep the "pointerness" away from the type and with the identifier ...
110
votes
6answers
20k views

Is every language written in C?

Sometimes while programming in different languages (C/C++, C#), this thought comes to my mind: Is each and every language written in the C programming language? Is the C language the mother/father ...
5
votes
2answers
191 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 ...
7
votes
1answer
244 views

Do any notable C extensions include integer types whose behavior is 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
5answers
122 views

Does it make sense to have a separate init function?

I'm created an opaque type and I have two options for its management. The first looks like this: type_t *a = type_init(); int err; err = type_do(a, "foo", "bar", FLAGBIT1|FLAGBIT2, NULL); if (!err) ...
0
votes
0answers
79 views

C: Using `extern const` in header files to make global variables read only [migrated]

I was experimenting with GCC and found out that you can declare variables const in header files but keep them mutable in implementation files. EDIT: This does actually not work, check my own answer. ...
4
votes
1answer
152 views

Using macros to implement a generic vector (dynamic array) in C. Is this a good idea?

So far I have only done personal projects at home. I hope to get involved in some open source project some time next year. The languages I that have been using the most are C and C++. I have used both ...
3
votes
0answers
57 views

Proper way of handling EINTR in libraries

What is the recommended etiquette when it comes to EINTR in libraries? I'm currently writing a function that does some file system tasks with the POSIX API, but a lot of the calls I use can ...
0
votes
0answers
3 views

Out of bound array elements being printed using gcc in Win8 [migrated]

I'm compiling the following code in my m/c using codeblocks and mingw32-gcc.exe v.4.8.1(tdm-2). #include <stdio.h> #include <stdlib.h> int main() { int a[8] = {3,1,10,-1,7,2,-8,1}; ...
9
votes
4answers
62k views

Is initializing a char[] with a string literal bad practice?

I was reading a thread titled "strlen vs sizeof" on CodeGuru, and one of the replies states that "it's anyways [sic] bad practice to initialie [sic] a char array with a string literal." Is this true, ...
6
votes
2answers
937 views

Why is C still in the category of High Level Language? [closed]

Many of the textbooks on the C programming language tell that C is a high-level programming language, but many of the tutors online say that C is also a middle-level programming language. Why is it ...
2
votes
5answers
259 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. ...
-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
183 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 ...
13
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 ...
3
votes
1answer
49 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 ...
1
vote
2answers
253 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 ...
58
votes
16answers
16k views

I don't know C. And why should I learn it? [closed]

My first programming language was PHP (gasp). After that I started working with JavaScript. I've recently done work in C#. I've never once looked at low or mid level languages like C. The general ...
10
votes
7answers
13k views

What Are Some Advantages/Disadvantages of Using C over Assembly? [closed]

I'm currently studying engineering in Telecommunications and Electronics and we have migrated from assembler to C in microprocessor programming. I have doubts that this is a good idea. What are some ...