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
4
votes
4 answers

What's the term *ANSI C* specifies if it used with GNU89, C89, GNU99, C99?

In Xcode IDE, I have an option to set C language dialect one of ANSI C GNU89 C89 GNU99 C99 Compiler Default I understand what they mean except ANSI C. Because As I know, ANSI C is just one of C89 or C99. But there should be a reason about it's on…
eonil
  • 83,476
  • 81
  • 317
  • 516
4
votes
4 answers

the size of dynamically allocated array in C

I know that this question has been asked before, but my question is more specific, here is the code: #include #include /* must be included for the time function */ main() { time_t t = time(NULL); srand((unsigned) t); …
4
votes
1 answer

‘struct in6_addr’ has no member named ‘s6_addr32’ with -ansi

I'm working through some compile errors when building OpenSSL with no-asm -ansi. I'm catching the error: $ ./config no-asm -ansi ... $ make ... gcc -DDSO_DLFCN -DHAVE_DLFCN_H -DOPENSSL_THREADS -DOPENSSL_NO_STATIC_ENGINE…
jww
  • 97,681
  • 90
  • 411
  • 885
4
votes
1 answer

sprintf() handling of %s extended ASCII (ISO 8859-1) on some runtimes?

I'm using ISO 8859-1 (Latin extended ASCII char set) in my C application. When I strcpy/strcat the portions of the string together, it works fine. But when I use sprintf("%s %s"), on some runtimes (particularly certain versions of Android), the…
user1054922
  • 2,101
  • 2
  • 23
  • 37
4
votes
2 answers

Ansi C: Long Double Variable Printing Out to a Value of 0.000000

When I run the Ansi C program below, a value of "0.000000" is printed out. Does anyone know why the value "561.308000" is not being printed out? I am using Dev-C++ to run the program, and the compiler I am using is: Mingw port of GCC (GNU Compiler…
4
votes
3 answers

Will the result be implementation-defined if one or two of the operands of the / or % operator are negative numbers?

e.g. What are the values of these expressions? Do they depend on the compiler? -7/3 -7%3 7/-3 7%-3 -7/-3 -7%-3
xiaokaoy
  • 1,608
  • 3
  • 15
  • 27
4
votes
6 answers

C struct elements alignment (ansi)

just a simple question... what the standard says about the structure members alignment? for example with this one: struct { uint8_t a; uint8_t b; /* other members */ } test; It is guarateed that b is at offset 1 from the struct…
Davide
  • 101
  • 7
4
votes
3 answers

Using strtol to validate integer input in ANSI C

I am new to programming and to C in general and am currently studying it at university. This is for an assignment so I would like to avoid direct answers but are more after tips or hints/pushes in the right direction. I am trying to use strtol to…
Lukaaaaaaaay
  • 141
  • 1
  • 4
  • 14
4
votes
1 answer

How can I read a text file and loop though repeating sections?

I have an ANSI 835 (text) file. For simplicity's sake it looks like…
Jeff Brady
  • 1,454
  • 7
  • 35
  • 56
4
votes
4 answers

Read all bytes from socket Stops at 52964 bytes

I'm making a Server that gets packages at 64 kb size. int length = 65536; byte[] bytes = new byte[length]; int pos = 0; while(pos < length -1) { System.out.println("Before read"); pos…
Eernie
  • 470
  • 3
  • 15
4
votes
1 answer

c free pointer to structure

I'm writing in plain C and I have an issue about how to free a pointer to a structure. I have a structure declared in the following way typedef struct _RealMatrix { uint nRows; uint nCols; real **matrix; } RealMatrix; Now, every time I…
gianluca
  • 337
  • 1
  • 3
  • 15
4
votes
1 answer

Self-Assignment in ANSI C

I am currently working on a embedded C project and I "inherited" some old code containing statements such as: rxStruct = rxStruct; where rxStruct is a variable. What could be the use of such statements?
4
votes
3 answers

Simple Delete File Program in ANSI C for Windows

Looking for a simple program to a delete a file written in ANSI C. Just as an example how would you delete a file at "C:\test.txt" with C?
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
4
votes
3 answers

Merge two bitfields according a bitmask

I wondering whether is it possible to use bit operations to merge two bitfields according a bitmask? For example I have two values, and a bitmask: char mask = 0x29; // 0010 1001 char a = 0x9; // 0000 1001 original value char b = 0xE8; // 1110…
hcpeter
  • 614
  • 3
  • 11
  • 24
4
votes
3 answers

Colored console output in Linux

I just started learning programming in C. the first problem was to choose on which platform should I learn it, and I selected Ubuntu. I found a GCC compiler to compile my projects, and it worked fine for me. I was running my compiled projects…
454b
  • 133
  • 2
  • 6
  • 12