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.

618 questions
3
votes
1 answer

Why are there alternative tokens in C++?

Possible Duplicate: Why are there digraphs in C and C++? What does the C ??!??! operator do?! In C++ there are alternative tokens for [] and {}, among others. E.g. the following code compiles: %:include int main() <% printf("Hello…
roim
  • 4,780
  • 2
  • 27
  • 35
3
votes
2 answers

Cast to type known only at runtime

let's say I have the following : void *pA; now I want at runtime to convert this pointer to a type that is not known at compile time. i.e. what is the equivalent or how to emulate in ANSI C a c++ dynamic_cast ? Thanks !
user1655490
3
votes
3 answers

C90 compound literals

In C99, if x was declared earlier and is of type v2, then I can write: x = (v2) { 1, 2 }; where v2 is: typedef struct { int x; int y; } v2; Can I do something similar in C90?
rid
  • 61,078
  • 31
  • 152
  • 193
2
votes
1 answer

ANSI-C pow function and type casting

This simple program below does not build for some reason. It says "undefined reference to pow" but the math module is included and I'm building it with -lm flag. It builds if I use the pow like pow(2.0, 4.0), so I suspect there is something wrong…
pocoa
  • 4,197
  • 9
  • 37
  • 45
2
votes
2 answers

Dequeueing in a LinkedList

I'm trying to get my dequeue method working on my implementation of a LinkedList ADT. However, it is removing from the beginning of the queue instead of the end. Any help with this? I'm new to C, and am trying to port a java exercise over to C..…
ChrisDevWard
  • 885
  • 2
  • 9
  • 20
2
votes
5 answers

Matrix Access Ansi C

Why the last printf in the main function doesn't print to the screen the value 10? I know that in ANSI C, statically allocated matrix are arranged in memory in this way: matrix: matrix[0][0],…
2
votes
1 answer

main function and variable after that

I saw a special definition of main() function, and I don't know how it is defined in this way? I haven't seen this style before. main (m1,s) char *s; { } I don't understand this way of defining a function. Complete code #include "stdio.h" #define…
2
votes
1 answer

Using a C++ String to open an fstream

In Visual Studio 2010, the following code works, even with the /Za (struct ANSI) compiler flag. string name = "input.txt"; ifstream fin; fin.open(name); All the documentation I can find seems to indicate that you have to pass a C-string to…
saulspatz
  • 5,011
  • 5
  • 36
  • 47
2
votes
3 answers

How to use the data from a structure in another C file?

I have defined a structure "data" in Main.c. I want to use the values of this structure in a function of another file app.c. Please suggest how to do this.
Rehan
  • 21
  • 2
2
votes
2 answers

literal division at compile time

Assume the following code: static int array[10]; int main () { for (int i = 0; i < (sizeof(array) / sizeof(array[0])); i++) { // ... } } The result of sizeof(array) / sizeof(array[0]) should in theory be known at compile time…
Łukasz Przeniosło
  • 2,725
  • 5
  • 38
  • 74
2
votes
3 answers

Converting large bit strings to hexadecimal in C

I need to convert large bit string like this : unsigned char* key = "0111010111010101010101010100101011010"; to hexadecimal strings like this : unsigned char* string = EBAAAA95A; The problem is that my keys are usually longer than 50 or 60 bits,…
Ouilliam
  • 61
  • 3
2
votes
5 answers

Practical way of implementing comparison of unions in c

For some testing purposes, I need to compare two unions to see if they are identical. Is it enough to compare all members one by one? union Data { int i; float f; char* str; } Data; bool isSame(union Data left, union Data right) { …
2
votes
3 answers

Why do C or C++ books not contain anything on networking?

I've just been looking at the following books: -K&R C -The Complete Reference C++ -The Complete Reference C -Deitel How to Program C -Deitel How to Program C++ and not one of them contains any networking, how to create sockets etc. Is there any…
Paul
  • 167
  • 2
  • 6
2
votes
1 answer

Why does setjmp() take 2 args on windows but only 1 arg on linux?

This setjmp.c builds in windows under Microsoft Visual Studio Professional 2019 (Version 16.10.1) Rebuild started... 1>------ Rebuild All started: Project: setjmp, Configuration: Release x64…
vengy
  • 1,548
  • 10
  • 18
2
votes
4 answers

G-WAN analogs

Today I found web-framework written in ANSI C - G-WAN. I like it, but it is not open source and maintained only by one developer. I am afraid of using it in production. Do you know any more serious frameworks, that allow to write web services in…
Nikolay Fominyh
  • 8,946
  • 8
  • 66
  • 102