Questions tagged [ansi-c]

ANSI C is an informal term sometimes used when referring to the C programming language standard published by the American National Standards Institute (ANSI) in 1989 .

"ANSI C" is an informal term used to refer to the 1989 version of the C language. The formal name for this version of the language is ISO/IEC 9899:1990. Informally it is also known as "C89" or "C90".

This is because the American National Standards Institute (ANSI) first published this standard in the year 1989, as a national standard for the USA. It became international ISO standard in the year 1990. So ANSI C, C89 and C90 all refer to the same technical standard.

It is a common misunderstanding that "ANSI C" means standard compliant C. The ANSI standard institute haven't had anything to do with C since 1989. The language is maintained by ISO SC22/WG14. Yet the term "ANSI C" is sometimes used to mean standard compliant, particularly in old books and by old compilers.

Because of this ambivalent meaning, please avoid using this tag. For questions regarding the C89/C90 version of the C language, please use . For questions regarding standard-compliant C, simply use the tag.

Further information about the different C standard versions.

203 questions
140
votes
33 answers

How to convert an enum type variable to a string?

How to make printf to show the values of variables which are of an enum type? For instance: typedef enum {Linux, Apple, Windows} OS_type; OS_type myOS = Linux; and what I need is something like printenum(OS_type, "My OS is %s", myOS); which must…
psihodelia
  • 26,430
  • 33
  • 104
  • 153
135
votes
5 answers

What is the difference between C, C99, ANSI C and GNU C?

I have started programming practice on codechef and have been confused by the difference between C and C99. What does C mean here? Is it C89? Check the languages at the bottom of this submit. It contains both C and C99. I found on the internet…
Aseem Bansal
  • 6,125
  • 11
  • 43
  • 80
99
votes
9 answers

Why doesn't ANSI C have namespaces?

Having namespaces seems like no-brainer for most languages. But as far as I can tell, ANSI C doesn't support it. Why not? Any plans to include it in a future standard?
Pulkit Sinha
  • 2,194
  • 3
  • 17
  • 20
52
votes
3 answers

String termination - char c=0 vs char c='\0'

When terminating a string, it seems to me that logically char c=0 is equivalent to char c='\0', since the "null" (ASCII 0) byte is 0, but usually people tend to do '\0' instead. Is this purely out of preference or should it be a better…
Joe DF
  • 4,909
  • 6
  • 34
  • 54
33
votes
2 answers

What does static mean in ANSI-C

Possible Duplicate: What does “static” mean in a C program? What does the static keyword mean in C ? I'm using ANSI-C. I've seen in several code examples, they use the static keyword in front of variables and in front of functions. What is the…
Sency
  • 2,536
  • 6
  • 38
  • 57
33
votes
4 answers

ANSI C vs other C standards

On several compilers I have used (all gcc but various versions) I get a C99 mode error for things like declaring int i inside the for loop expression instead of before it (if I do not use the std=c99 option). After reading here I understand that…
ubiquibacon
  • 9,834
  • 25
  • 101
  • 175
27
votes
5 answers

Who defines C operator precedence and associativity?

Introduction In every textbook on C/C++, you'll find an operator precedence and associativity table such as the following: http://en.cppreference.com/w/cpp/language/operator_precedence One of the questions on StackOverflow asked something like…
Fiddling Bits
  • 8,362
  • 3
  • 24
  • 41
25
votes
8 answers

ANSI C equivalent of try/catch?

I have some C code I'm working with, and I'm finding errors when the code is running but have little info about how to do a proper try/catch (as in C# or C++). For instance in C++ I'd just do: try{ //some stuff } catch(...) { //handle error } but…
aiden
  • 259
  • 1
  • 3
  • 3
24
votes
2 answers

fopen for everything - is this possible?

I used to programing windows, but I want to try my hand on making a cross-platform application. And I have some questions, if you don't mind: Question 1 Is there some way to open UNICODE\ASCII file and automatically detect it's encoding using bare…
Anonymous
  • 347
  • 2
  • 8
22
votes
1 answer

Difference between char* var; and char *var;?

Just wondering if there's any difference between: char* var; char *var; or is it just a matter of preference (spacing)?
Joe DF
  • 4,909
  • 6
  • 34
  • 54
20
votes
4 answers

Should I use ANSI C (C89)?

It's 2012. I'm writing some code in C. Should I be still be using C89? Are there still compilers that do not support C99? I don't mind using /* */ instead of //. I'm not sure about C89 forbids mixing declarations and code. I'm kind of leaning…
mk12
  • 24,644
  • 29
  • 92
  • 132
19
votes
6 answers

Multi-Dimensional Arrays in C: are they jagged?

A simple question about the C programming language (ANSI-C): Are the multi-dimensional arrays in C jagged? I mean - are we talking about "array of arrays" (one array of pointers to other addresses in the memory) , or this is just "long…
Programmer
  • 700
  • 1
  • 9
  • 15
13
votes
2 answers

Are there any differences between ANSI C and ISO C?

I understand that there is both an ANSI standard and an ISO standard for C. Are there any differences between these two standards? If so, what are they? And if there is not a difference then what's the point of having two standards?
Earlz
  • 57,517
  • 89
  • 275
  • 484
13
votes
2 answers

Error: initializer element is not computable at load time

I have a function that takes a struct, and I'm trying to store its variables in array: int detect_prm(Param prm) { int prm_arr[] = {prm.field1, prm.field2, prm.field3}; return 0; } But with gcc -Wall -ansi -pedantic-errors -Werror I get the…
zxcv
  • 6,921
  • 8
  • 32
  • 30
12
votes
4 answers

All struct identifiers are automatically forward declared

While answer warning: assignment from incompatible pointer type for linklist array, I noticed any undeclared identifier perceded with struct keyword are considered as forward declared identifiers. For instance the program below compiles well: /*…
Mohit Jain
  • 29,414
  • 8
  • 65
  • 93
1
2 3
13 14