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 does GCC C89/C90 ANSI C use __STDC_VERSION__ in Eclipse?

I need to confirm my code if I'm using ANSI C (C89/C90) and I notice this: Even if I have selected ASNI C (C89/C90) standard in Eclipse CDT. Question: It is told that ANSI C does not use __STDC_VERSION__ but why do I see the same value for…
euraad
  • 2,467
  • 5
  • 30
  • 51
3
votes
6 answers

Remove white chars between commas, but not between what inside the commas

I'm new to C and learning C90. I'm trying to parse a string into a command, But I have a hard time trying to remove white chars. My goal is to parse a string like this: NA ME, NAME , 123 456, 124 , 14134, 134. 134 , 1 into this: NA…
Sheilem
  • 59
  • 5
3
votes
2 answers

Is the format specifier %[^\n]s legal in C89?

I'm reading a string from sdin with a scanf by doing: scanf("%[^\n]s", msg); %[^\n]s reads till a new line character is found. Is this legal in ANSI-C?
Foxen
  • 35
  • 6
3
votes
2 answers

Does ansi C place a limit on the size of a program in memory?

I've been told this, and couldn't find a confirmation or rebuttal on the web. Is this true? If so, which is the limit? Is it usually enforced by compilers?
Emilio M Bumachar
  • 2,532
  • 3
  • 26
  • 30
3
votes
1 answer

Problem with K&R C book regarding how scanf deals with blanks and tabs in the format string?

Reading the famous book The C programming language ANSI C second edition by Brian Kernighan and Dennis Ritchie, I found in chapter 7 (section 7.4. page 157) this paragraph below which describe the format string for scanf: [...] The format string…
3
votes
1 answer

Do I even need `-pedantic` if I specify the standard to ANSI C with `-std=c89`?

If I specify the standard to ANSI C with -std=c89, my code won't run until I perform certain changes to make it compliant with the standard. So do I even need -pedantic at this point if I've already set the -std=c89 flag? By the way, the idea was…
finefoot
  • 9,914
  • 7
  • 59
  • 102
3
votes
3 answers

clarification for RAND_MAX and rand() in c stdlib.h

why does the following c code produce real numbers only ranging between 0 and 1(eg: 0.840188,0.394383...etc) for double a,b when the value for RAND_MAX appears to be 0.000000 . Shouldn't RAND_MAX set the maximum value for the number generated by…
3
votes
7 answers

How to divide an Int into two Bytes in C?

I am working with software embedded in minimal hardware that only supports ANSI C and has minimal versions of the standard IO libraries. I have an Int variable, two bytes in size, but I need to divide it into 2 bytes separately to be able to…
Curious
  • 111
  • 1
  • 1
  • 10
3
votes
1 answer

How to suppress PC-Lint Note 970 for int main(void) function?

I have a Visual Studio Windows Console application with ANSI C code. The main function definition is something like: int main(void) { // do stuff return 0; } However, PC-Lint reports the below message for the int type Note 970: Use of…
Cem Polat
  • 101
  • 1
  • 7
3
votes
2 answers

How do strings work in C?

String is said to be a constant in C programming language. So, when I give a statement like char *s = "Hello", I have learned that s points to a memory location of H since "Hello" is stored in some static memory of the program and also "Hello" is…
Tarun Maganti
  • 3,076
  • 2
  • 35
  • 64
3
votes
2 answers

c | compare string format

I want to find out if there is any simple option to a string is equal to a format string. for example I want this format .mat[something][something] to be equal to using strcmp to .mat[r1][r2] or .mat[4][5] Is there any option to use regular…
Elon Salfati
  • 1,537
  • 6
  • 23
  • 46
3
votes
2 answers

ANSI-C constant-expression function like C++ constexpr?

Putting it simple, is there an ANSI-C way of making a function a constant expression? Pure ANSI-C but GNU extensions are acceptable - NO C++, though. Preferably without relying on macros. Something that surely behaives like the C++ constexpr and…
j4x
  • 3,595
  • 3
  • 33
  • 64
3
votes
2 answers

Flex/Bison based lexer/parser for C language

Is there a simple lexer/parser for C language or a subset of it which is based on Flex/Bison? I have found some open source parsers for C (TCC, LCC, ...) but none of them are based on bison.
Mahdi
  • 1,871
  • 2
  • 24
  • 41
3
votes
3 answers

Anonymous struct with ANSI C

I want to know if it is possible to declare anonymous structs in ANSI C. The code I have is: struct A { int x; }; struct B { struct A; int y; }; When I compile it I get: warning: declaration does not declare anything I have read that…
Klas. S
  • 650
  • 9
  • 21
3
votes
1 answer

C program to perform a pipe on three commands

I have to write a program that will perform the same operation that du | sort | head in the command line would do, but I'm stuck, and my program is not working. The output right now is 112 . and the program doesn't terminate. Please help, I don't…
CSstudent
  • 43
  • 1
  • 7