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

how to download an unrestricted line from a file using the fread function?

I have a question how to download a line of text from the file without specifying the size of this line? I wouldn't want to use fgets because you have to give the fgets to the characters in advance. I can load the whole file, but not one line.…
Roundstic
  • 21
  • 3
1
vote
1 answer

Getting system's max allowed path length in c

How can I determine the maximum file path length allowed in the system my program is running on? Is it in limits.h? because I didn't find it there.
avivgood2
  • 227
  • 3
  • 19
1
vote
1 answer

C. double free or corruption (!prev) Aborted (core dumped)

I'm trying to use a "fixed memory scheme" and pre-allocate memory & reuse it via alloc, init, free fashion as many times as possible. free() will called at shutdown only, but I want to test many iterations. Although I call my alloc function …
cyber101
  • 2,822
  • 14
  • 50
  • 93
1
vote
1 answer

Is freopen() part of ansi c?

I got an assignment in which I can use any method, as long as it is part of the ANSI - c standard. I want to use freopen, except I don't know if its part of the standard. I have looked at "The C programming language" book's list of methods and it…
avivgood2
  • 227
  • 3
  • 19
1
vote
1 answer

Point to functions with different arguments using the same pointer

I am trying to build a parser to a given input, there are 8 possible commands. So I figured that instead of using the ugly technique of a case switch block like that: switch(command) case cmd1: .... /*call a function that do cmd1*/ case…
Aviv Aviv
  • 129
  • 1
  • 10
1
vote
2 answers

Printing a binary representation of float/double gives the same result for two different numbers

I have to print a binary representation (from the memory) for float / doubles. While it's working pretty nicely for integers, I got strange behavior for some floats. I mean, the results for 3.14 and 21.37 are the same (as double). For 8.5 I'm…
Jakub
  • 50
  • 1
  • 6
1
vote
2 answers

gSoap generated client-side structure initialization and use

gSoap generated client-side structure initialization and use (using ANSI C bindings) After reading through gSoap examples and documentation I was not able to find anything directly answering this issue. I have since sorted it out. This post/answer…
ryyker
  • 22,849
  • 3
  • 43
  • 87
1
vote
0 answers

Possible bug introduced since Spring 5.0 regarding RFC1123; ANSI C's asctime

It would appear that since Spring 5.0 the DateTime format: ANSI C's asctime() as specified in the RFC2616 no longer gets parsed correctly when a single-digit is provided (i.e; 9 rather than 09). When looking at the test-method:…
1
vote
7 answers

ANSI C splitting string

Hey there! I'm stuck on an ANSI C problem which I think should be pretty trivial (it is at least in any modern language :/). The (temporary) goal of my script is to split a string (array of char) of 6 characters ("123:45") which represents a…
Asmodiel
  • 1,002
  • 1
  • 12
  • 21
1
vote
1 answer

How to make lock / critical section in embedded ANSI C?

I have code like this: (very simplified code) // This is code for Microchip 8-bit microcontroller, XC8 compiler (GCC based) #define TIMER_COUNT 8; volatile uint16_t timer_values[TIMER_COUNT]; volatile uint16_t timer_max_values[TIMER_COUNT]; //…
Kamil
  • 13,363
  • 24
  • 88
  • 183
1
vote
2 answers

Voltage Measurement on STM32

Im new in ANSI C @STM32 but I tried to measure a Voltage (~12V) with a voltage divider and a Analog GPIO. I tried: value = HAL_GPIO_ReadPin(VOLTAGE_GPIO_Port, VOLTAGE_Pin); But it always return 0 Then I tried to use the ADC (I dont know that…
guenthernagel
  • 73
  • 1
  • 3
  • 14
1
vote
0 answers

Data separation issues in a merge

I'm currently trying to perform a merge between two CSV text files(file_a and file_b) into a third file (file_c). All files are sorted by lowest id. However, I've observed that, when checking file_c's content, the last entry from file_a is repeated…
1
vote
2 answers

incompatible types when returning type

I have a problem on convertToPoint functions. int convertToPoint(int argc, char *argv[]) { struct point p; int x, y; p.x = atoi(argv[1]); p.y = atoi(argv[2]); return p; } Expect to return a struct of type point, but receive the follow…
lukaswilkeer
  • 305
  • 4
  • 13
1
vote
1 answer

Safest way to read a string and store as int in a struct

I am using ANSI C on the gcc compiler (with -ansi). I need to read user input for the month, day, hour and minute into a struct and they: cannot be of datatypes that are not an int, each need to conform to individual criteria (i.e. month > 0 &&…
Davide Lorino
  • 875
  • 1
  • 9
  • 27
1
vote
0 answers

EOF not detected using scanf

I created a function which should read some integers from file to an array. The function should also catch cases where there aren't enough integers to fill the array, and terminate (i.e. EOF reached while filling the array). My problem: the function…
P.Diddy
  • 34
  • 6