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
1
vote
1 answer

Cmake passing arguments

I have a program to recognize files based on their signatures. Works great. But I'm new to C and am now trying to get an IDE called CLion to work. However, I can't figure out how to add command arguments to cmake - such that when I run main and…
Avallauch
  • 65
  • 2
  • 11
1
vote
0 answers

Extracting information from a bunch of string into an array

Let's say I have this kind of string information: /* There are a total of 10 entries in the algebraic variable array. There are a total of 4 entries in each of the rate and state variable arrays. There are a total of 8 entries in the…
1
vote
1 answer

Adding a pointer to size_t in C89

First, I know about this thread: Now Assume I have this array: size_t count = some_value(); struct info *pinfos = malloc(count * sizeof(struct info)); and I wanted to "navigate" it using the variable struct info *p; Can I use this…
Bite Bytes
  • 1,455
  • 8
  • 24
1
vote
1 answer

Why int exists in C, Why not just short and long

A short is at least 16 bits and a long is at least 32 bits, so what's the point of an int which can be either 16-bit or 32-bit? PS: I'm talking about ANSI C here.
Bite Bytes
  • 1,455
  • 8
  • 24
1
vote
1 answer

Ansi C int16_t reference to int8_t array

I'm stuck with the above problem. Having an int8_t array: int8_t i8array[3]; i8array[0] = 10; i8array[1] = 15; i8array[2] = 100; And I want to not just convert but also reference an int16_t onto i8array[1]. So I want a new variable i16var, which is…
Daniel
  • 2,318
  • 2
  • 22
  • 53
1
vote
1 answer

Why are my MaxHeapify and BuildMaxHeap procedures failing to organise a heap?

In my ansi-c implementation of heap I have two procedures: void MaxHeapify(Heap * h, int i) { int l = Left(i); int r = Right(i); int L, tmp; if(l < h->heapsize && h->data[l] > h->data[i]) L = l; else L = i; if(r <…
residue
  • 207
  • 5
  • 18
1
vote
1 answer

Using ANSI-C quoting in sed

I have a file named "insert.txt". It can look like this (or uglier): ASDFG?|??|?\/\HJKL And I want to replace a block of text in a target file…
stackmate
  • 908
  • 9
  • 17
1
vote
1 answer

function not printing correctly in c

I am trying to build a dynamic maze i got to the part where i get the size and get the chars that i need to build the maze from them. but the function thats build the maze prints it really asymmetrical how can i fix that? my code: #include…
1
vote
1 answer

UVa - Longest Nap

well it's been pretty hard find an answer since I don't know how to express this in english to find out! So, I'm trying to do the Longest Nap problem: https://uva.onlinejudge.org/external/101/10191.pdf My code is working but I keep receiving wrong…
1
vote
2 answers

gcc floating point with and without -ansi disparity

Consider the two programs. First one prints "Unequal" on gcc 5.3.0 (target: i686-pc-cygwin). When -ansi option is used "Equal" is printed. int main () { double d = 2.335 - 2.334; double q = 0.001; if (d == q) { …
lukeg
  • 4,189
  • 3
  • 19
  • 40
1
vote
2 answers

How to see the assembly code from a Ansi C hello world written in Visual Studio?

I'm playing with Ansi C in visual studio, created the simple Ansi C program (I had to change VS configuration to not use cpp but ansi c) int a = 0; int b = 0; printf("Hello World! \n\n"); system("PAUSE"); return 0; I compiled it and it generated…
RollRoll
  • 8,133
  • 20
  • 76
  • 135
1
vote
3 answers

Why does the atof() function not return 0 when I pass it a string with invalid characters after a number?

I need to convert a string into a float. If the string is not a number I wish to return 0. I have tried to test if the atof() function would work for this by using the following code: printf("%f", atof("1a")); From my understanding of atof, the…
JinKazama
  • 81
  • 3
  • 15
1
vote
1 answer

C fgets() to get input until EOF rather than enter twice

I'm creating a program that reverses every line of input. This is my code: #include #include int main() { char c[100]; while((fgets(c,100,stdin)) != NULL) { c[strlen(c) - 1] = '\0'; for(int…
forfun
  • 67
  • 5
1
vote
1 answer

How to accomplish simulation of nested function in ANSI C where i can dynamicaly update my functions? pls look at whole explanation

I am new to this community and I would like to ask one question. I am not programer/developer but I use programing to accelerate my scientific computes. In past i have used a lot python, but now because of my new jobs I need to use C programing…
Branko
  • 11
  • 2
1
vote
1 answer

Why is Xcode allowing me to declare C variables anywhere?

I created a basic C project in Xcode and modified the starter code in main.c slightly. I also went into the build settings and told it to use ANSI-C. Here's the code I have: int main(int argc, const char * argv[]) { // a statement! …
kromenak
  • 479
  • 5
  • 13