Questions tagged [c]

C is an imperative (procedural) systems implementation language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language. from http://en.wikipedia.org/wiki/C_(programming_language)

C (pronounced "See", like the letter C) is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the UNIX operating system. Its design provides constructs that map efficiently to typical machine instructions, and therefore it found lasting use in applications that had formerly been coded in assembly language. It is highly efficient procedural oriented programming language, has emphasis on functions whereas latest object oriented programming languages having emphasis on data.

Although C was designed for implementing system software, it is also widely used for developing portable application software.

C is one of the most widely used programming languages of all time and there are very few computer architectures for which a C compiler does not exist. C has greatly influenced many other popular programming languages, most notably , which began as an extension to C.

Design

C is an imperative (procedural) systems implementation language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language.

Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with few changes to its source code. The language has become available on a very wide range of platforms, from embedded micro-controllers to supercomputers.

Tag usage

Questions that are not related to microcontroller programming or embedded firmware should be asked at Stack Overflow.

When posting questions about C programming, please make sure to include:

  • Target system & compiler version, including the specific CPU/microcontroller part that is used.
  • Unless the question explicitly mentions which version of the C standard that is used, it is assumed that the current version is used. That is, whichever version of ISO 9899 that ISO currently lists as active. Please have this in mind when answering or commenting on questions tagged .
  • Relevant flags/switches passed to the compiler, assembler or linker if applicable.
  • Verbatim copies of compiler warnings or errors if applicable. Please post them as text and not as screen shots.
  • Snippets of source code identified as problematic by the compiler if applicable. Note that many compilers stay silent by default as long as they are able to compile your code, so you have to explicitly enable compiler warnings. With the widely used GCC for example, you should always pass -Wall -Wextra -pedantic on the command line.

Is it C, C++ or both?

This tag is for questions related to C, not C++. In some cases, you may be working with both and applying both tags is entirely appropriate. However, please refrain from using both tags in an effort to help your question reach a wider audience. After all, C++ answers won't help you solve the problem in C, and good C answers often do not describe the best approach in C++.

Important notes that may save you time

1637 questions
6
votes
5 answers

What language do microcontrollers use apart from C?

I want to start making devices and I read about microcontrollers and other stuff on the Internet. I wonder if there are other languages to program microcontrollers with in addition to C.
user2635745
  • 63
  • 1
  • 4
4
votes
4 answers

Problems with structures and unions in c

After many years I started for fun to program in C again. Now I have an issue with the use of structures and unions. The declaration: typedef struct { unsigned char SOAKTEMP; unsigned char SOAKTIME; unsigned char …
Decapod
  • 3,930
  • 10
  • 24
4
votes
3 answers

Converting c file to HEX

I am new to Embedded systems. I am starting my learning with AT89C51. My first target will be LCD interfacing. I have a programmer an LCD and a microcontroller. But the program is written in C or assembly language and I need a .HEX file to burn. How…
Zain
  • 423
  • 2
  • 6
  • 13
3
votes
2 answers

Initialization nested struct in C

I have the following nested struct definition in my .h file: struct PARAM { uint8_t data1; uint8_t data2[2]; uint8_t data3[2]; }; struct CONFIG { uint8_t data4; struct PARAM par1; struct PARAM par2; }; In my main.c file I…
syn_dm
  • 59
  • 1
  • 5
1
vote
2 answers

Why using a pointer interfacing LCD HD44780

I'm trying to interface with an LCD display (HD44780). I came across a tutorial on the internet to send characters and strings to the display. Everything went well and it works fine but I have no idea why a pointer is used. I'm not quite familiar…
ChThy
  • 335
  • 1
  • 11
0
votes
3 answers

How can I use a global variable in a STM32WB55 BLE application?

I am building a BLE-based application for a STM32WB and the problem I have is that I have two programs, main.c and custom_stm.c and I want to use the same variable in both (the second program continuously updates it). The main.c program is located…
Theodor
  • 65
  • 6
0
votes
3 answers

Programming binary values [0000 to 1111] to port pins in C?

I'm using PIC 89v51 microcontroller, and i have to generate voltages from port pins of a particular port [i have used R2R ladder ckt in hardware] but the thing is i need to generate it from the microcontroller only i.e. i have taken four port pins…
angiey
  • 1
  • 1
0
votes
1 answer

Bitwise OR operator confusion

Can anyone tell me the difference between the following two assignments? control_reg |= (1<<2) | (1<<4); control_reg = (1<<2) | (1<<4);
knight
  • 53
  • 9
0
votes
1 answer

Problem in c language

I need a and b value. a=2; b=a+=++a; a+=-b; Solution is: a=0 b=6 Why is this the right answer? I know it's simple but I am sure I'm doing something wrong. Tried so many times to do it that I can't even think.
cerouno
  • 67
  • 6
0
votes
1 answer

how a number is stored in processor

Background: I am sampling a signal from accelerometer at a rate of 20KHz( period of every 50 micro seconds). I need to store this information in memory card. Kit: STM32F40, IDE: Keil. ADC Input is 8 bit. I am trying to store numbers…
0
votes
2 answers

How to make if condition run once in while(1)

I am intergrating inputs and uart in PIC MCU. My program is if I press a switch, this info is send to terminal but the problem is it keep on displaying until I release the switch. I want it to be displayed just for once regardless of how much time…
anna carolina
  • 366
  • 1
  • 5
  • 17
0
votes
3 answers

Tools to compile pointers to arrays of static size

Are there any static code analyzing tools for C that convert pointers to arrays of a static size? It is a marginal pain and I just figured I'd check with the community. A quick google search did not turn up anything useful because "to" in the phrase…
eatonphil
  • 101
  • 3
0
votes
2 answers

sbit definitions with SDCC - Error: "initializer element is not constant"

I am facing this error when try to compile a C program using the SDCC compiler: The part of programme that is causing error. include(reg51.h) define cmdport P3 define dataport P2 define q 100 (following 3 line are causing error.) sbit at …
Zain
  • 423
  • 2
  • 6
  • 13
-1
votes
1 answer

Assign a pointer element of structure to an array

typedef struct { int a; int* b; } foo_t; int main (void){ foo_t foo; int array[10]; foo.b= &array[0]; } Here is a sample code. As you know, if we define a structure, this structure allocates a memory as its total capacity. In…
IHK
  • 99
  • 6
-1
votes
1 answer

Atme ICE basic connection

I got Atmel ICE basic, 6pin wire and atmega 1248, how I should connect the pins. I tried to look from data sheet, but I cant sent the code in atmega.…
1
2