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
2
votes
1 answer

C - code compatibility

How to make sure, that my code is compatible with every gcc compiler set to the most strict level? Is there any tester tool or do I need to test it manually somehow? Thanks
user10099
  • 1,345
  • 2
  • 17
  • 23
2
votes
1 answer

Compile ansi c vendor library with objective-c

I'm using ObjC to build my app's ui, and my app depends on an ansi c library, I have the ansi c library's source code. How can I use Xcode to compile this app (For development, I can install the library into my Mac). But I want to ship my app to…
jiluo
  • 2,296
  • 3
  • 21
  • 34
2
votes
1 answer

Netdb.h in Ansi C

Is there a way to use netdb.h in ansi C? I want to use gcc with -ansi flag, but I have similar erros like in this post netdb.h not linking properly , is it possible to solve the ansi c - compliance? If not what networking libraries should I use?
Pio
  • 4,044
  • 11
  • 46
  • 81
2
votes
1 answer

Function to read a key without waiting for LF

I'm looking throughout the Internet in search of some function that will read a key from keyboard without waiting for LF (like getch() from conio.h). Unfortunately I have to compile it with gcc using switches -ansi and -pedantic, which makes getch()…
Sushi271
  • 544
  • 2
  • 8
  • 22
2
votes
3 answers

Strict standards-compliance with Visual C++

This question is not the same as either of these: Setting Visual C++ Studio/Express to strict ANSI mode Is there an equivalent to -pedantic for gcc when using Microsoft's Visual C++ compiler? I am running Windows 7 and Visual Studio Express 2012,…
Grault
  • 974
  • 12
  • 31
2
votes
3 answers

How can allocate multi dimensional array at run time?

at design time I could have declare a variable like this: char szDesignTimeArray[120][128]; The above declaration is 120 arrays of size 128. At run time I need to allocate the following: char szRunTime[?][128]; I know the size of the arrays but I…
Sunscreen
  • 3,452
  • 8
  • 34
  • 40
2
votes
2 answers

How is this program meant to work?

I've been reading The C Programming Language by Kernighan and Ritchie and very early own I came across a program that didn't work, even though I copied it directly from the book. Here is a screen cap of the description -…
Geesh_SO
  • 2,156
  • 5
  • 31
  • 58
2
votes
4 answers

ANSI C - Tips on creating good API interfaces

I'm trying to create an API that is easy to use correctly and hard to use incorrectly. Imagine you had a function "bool MyObject_SetLocalDateTime(MyObject *pMyObject, params...)" which allows client to set date and time in YYYY MM DD HH MM SS…
jpen
  • 2,129
  • 5
  • 32
  • 56
2
votes
2 answers

Is this true for ANSI C?

"The const and volatile qualifiers may precede any declaration." I saw this statement marked as true in an online test series. But in standard C(89) I can see declaration: declaration-specifiers init-declarator-listopt…
perilbrain
  • 7,961
  • 2
  • 27
  • 35
2
votes
3 answers

Implicit declaration of function fmax

I have the following code: #include #include int main(void) { printf("%f\n", fmax(1.2, 3.4)); return 0; } If I compile with: gcc a.c -o a && ./a then I get the expected output: 3.400000 If I try to enable warnings…
rid
  • 61,078
  • 31
  • 152
  • 193
2
votes
3 answers

ANSI C - Clearing a string

I've got a string declared like this: str=malloc(sizeof(char)*128); I want to clear it completely so that whenI do strncat() operation, the new characters will be written to the beginning of str. The reason I need to clear it is that I'm writing…
nick_name
  • 1,353
  • 3
  • 24
  • 39
2
votes
4 answers

Parsing commands shell-like in C

I want to parse user input commands in my C (just C) program. Sample commands: add node ID add arc ID from ID to ID print exit and so on. Then I want to do some validation with IDs and forward them to specified functions. Functions and…
DavidMG
  • 105
  • 1
  • 5
1
vote
1 answer

Using ANSI C to extract binary image data from database into a .jpg file

I am using an ANSI C compiler (LabWindows/CVI version 2010) to extract integer, string and floating point data from an existing Access 2010 database with good success. However, I have not been able to extract image data stored as long binary data…
ryyker
  • 22,849
  • 3
  • 43
  • 87
1
vote
4 answers

search a string in an array of strings

I keep getting bad pointers. Can anyone tell me what am I doing wrong? int SearchString( char* arr[], char* key, int size ) { int n; for ( n = 0; n < size; ++n ) { if ( strcmp(arr[n], key) ) { return n; } } return -1; } char…
Nahum
  • 6,959
  • 12
  • 48
  • 69
1
vote
2 answers

Why doesn't my array store the struct correctly?

I'm having quite a bit of trouble with something that should be really simple. In my program I have a struct called "Run": typedef struct{ char name[MAXNAMELENGTH], day[MAXDAYLENGTH]; int distance, intDay; Date startDate; Time…
Goibon
  • 251
  • 3
  • 17