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
2 answers

type conversion warnings in porting 32 bit app to 64 bit app using sizeof operator

I am porting an application from 32 bit to 64 bit. The application includes gSoap generated ANSI C source code. The prototypes of several generated soap functions include int data types in the argument list, such as: int PASCAL FAR setsockopt ( …
ryyker
  • 22,849
  • 3
  • 43
  • 87
2
votes
3 answers

How to tell, in C, if parameters to a function are provided?

In C, when you declare a function without parameters, that function can accept any number of parameters. Example: int sum() { // some code } int subs(void) { // some code } int main() { sum(1, 2, 3, 4, 5, 6); // This is valid subs(1,…
Werem
  • 534
  • 2
  • 5
  • 16
2
votes
2 answers

How do I use sscanf to get names and print them out the way i want them to

I'm making a program that takes names from the user seperated by commas. The program allows the user to put as many or as little spaces as they want between the commas. So for example: If I were to type something like Smith, John or Smith,John I…
user798774
  • 403
  • 2
  • 8
  • 20
2
votes
6 answers

Why do I have to deallocate the pointer after using it??? (ANSI-C)

I read this: http://www.drpaulcarter.com/cs/common-c-errors.php#2.8 and there's a block of code like that: #include #include int main() { char *st = malloc(20); /* st points to allocated array*/ strcpy(st, "abc"); /* st…
Hieu Nguyen
  • 1,497
  • 3
  • 12
  • 15
2
votes
0 answers

High accuracy formula for division of complex numbers

Now I am working on implementing complex numbers for ANSI C, but some mathematical formulas need improvement because floating point numbers are prone to loss of precision. In my implementation, I prefer double for represent of real numbers. I'm…
PavelDev
  • 579
  • 4
  • 12
2
votes
2 answers

function parameter type checking in ANSI-C with empty parameter list

In K&R it says that declaring a function prototype such as void foo(); with an empty parameter list turns off function parameter type checking. Is this only for foo or for all functions?
Robert S. Barnes
  • 39,711
  • 30
  • 131
  • 179
2
votes
1 answer

gSoap - service call returns with SOAP_OK, but return struct uninitialized

This is a dereference of null pointer problem - in both the ANSI C & gSoap domains: I am using the following public WSDL: http://www.mobilefish.com/services/web_service/countries.php?wsdl and have tested its behavior using soapUI. I created…
ryyker
  • 22,849
  • 3
  • 43
  • 87
2
votes
5 answers

Is there any way to pass an array of an unknown type as a parameter to a function in C?

I've been trying to improve my skills and knowledge in C. Today I've tried to create a function that takes an array of any type, but I haven't found a successful way, I'm using ANSI C and I tried to pass it as a void pointer, but when I'm trying to…
Albert
  • 23
  • 1
  • 5
2
votes
2 answers

How to implement OTA update failover scenario for STM32F4 microcontroller's flash banks?

I am using the 32bit ARM STM32F439ZI microcontroller for my project. The microcontroller has 2 megabytes of flash memory organized into 2 banks of 1 megabytes each for simultaneous read and write/erase, as the datasheets points out. I want to…
burnersk
  • 3,320
  • 4
  • 33
  • 56
2
votes
1 answer

Program does not use all cores

I have a complex program which should use all cores to perform complex math calculations. I have a system with two Intel Xeon Platinum 8160. Each of them has 24 cores so together I have 48 cores and 96 threads. My program only uses 24 cores and not…
Felix
  • 5,452
  • 12
  • 68
  • 163
2
votes
0 answers

Execute c program with double quote argument

I am using ubuntu and using "/bin/bash" as my default bash. I have a simple c program (test_arg.c) that prints the arguments. #include void main(int argc, char **argv) { for(int i=0; i < argc; i++) { printf("arg[%d]:%s \n", i,…
ABCDEFG
  • 187
  • 3
  • 11
2
votes
2 answers

Scan and swap string values with regex in ANSI C

I want to transform a given input in my c program, for example: foo_bar_something-like_this into this: thissomethingbarfoolike Explanation: Every time I get a _, the following text up to, but not including, the next _ or - (or the end of the line)…
2
votes
3 answers

Why does free work like this?

Given the following code: typedef struct Tokens { char **data; size_t count; } Tokens; void freeTokens(Tokens *tokens) { int d; for(d = 0;d < tokens->count;d++) free(tokens->data[d]); free(tokens->data); …
Parad0x13
  • 2,007
  • 3
  • 23
  • 38
2
votes
0 answers

Why doesn't ANSI C directly expose the overflow and carry flags?

Given int x = a number; int y = some number; int z = x + y; // did overflow occur? At least on Intel chips, overflow detection is possible through the overflow flag. But there's no direct way to get to it through ANSI C. Why not? NOTE: The…
Curious
  • 128
  • 5
2
votes
3 answers

A friend sent me a snippet I don't understand. How does this work?

I spent some time trying to understand what was going on with this code but in the end I couldn't fully figure it out. void knock_knock(char *s){ while (*s++ != '\0') printf("Bazinga\n"); } int main() { int data[5] = { -1, -3, 256, -4, 0 }; …
Khryus
  • 347
  • 3
  • 12