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

Conditional Compilation and compile time evaluation of expressions in ANSI C

I would like to do the following, but the compiler doesn't like it: unsigned short foo = 1; // do something with foo #if sizeof(short) * CHAR_BIT > 16 foo &= 0xffff; #endif I know this expression can always be fully evaluated at compile time,…
Robert S. Barnes
  • 39,711
  • 30
  • 131
  • 179
1
vote
1 answer

? operator in sscanf regular expression

I'm trying to parse an extension out of a list of files of the format 'filename.extension'. However in the cases where filename is blank, I'm getting undesired results. For example.... sscanf(my_string,"%*[^.].%s",file_ext); Will properly parse…
jparanich
  • 8,372
  • 4
  • 26
  • 34
1
vote
1 answer

How do I read a string until a comma in C89?

I am trying to read a CSV file in c89 using scanf: FOO,2,3 BAR,5,4 ... This is what I have tried: #include int main() { char code[10]; double a,b; while( scanf("%s,%lf,%lf", code, &a, &b)!=EOF ) { printf("> %s\n",…
M.E.
  • 4,955
  • 4
  • 49
  • 128
1
vote
3 answers

How to pass other variables as args along with std::ostream in a function in C++?

I was working on a function which looks like so: inline std::ostream& mvUp(int n,std::ostream& ss){ char u[8]; sprintf(u,"\033[%dA",n); ss<
DarthCucumber
  • 101
  • 1
  • 8
1
vote
1 answer

What type of memory is pointer pointing to in c?

I am trying to understand pointers more deeply and I got to a situation where I don't know to what type of memory do the pointers point to. Do I understand it correctly that if the pointers point to dynamically allocated variables through malloc()…
Fildo7525
  • 13
  • 4
1
vote
1 answer

ANSI C pointers to java

Since some weeks ago I have been trying to convert this c and other c function to java language (i'm a newbie on it). My first problem is how-to convert to java code, the pointers on lines like: q = fdata + ind; datend = fdata + buff_size; For…
user844178
  • 11
  • 2
1
vote
1 answer

Integer x; is syntactic error or semantic error?

This is an ANSI C program. Which part of the seven-phase C compiler will throw an error? The community is divided between Syntax Analyzer and Semantic Analyzer. int main() { Integer x; return 0; } Declaration: This question was asked in the…
Baban Gain
  • 614
  • 6
  • 21
1
vote
1 answer

Linux pipes and select

There is a shell script #!/bin/bash while : do echo "++stdout.."; echo "++stderr.." >> /dev/stderr; sleep 1 done and c prog #include #include #include #include #include #include…
1
vote
1 answer

"Function prototypes are an ANSI feature" error while compiling C program

I am attempting to debug a compiler error on an old HP 3000 MPE/iX Computer System. The error is: cc: "func.c", line 8: error 1705: Function prototypes are an ANSI feature. cc: "func.c", line 15: error 1705: Function prototypes are an ANSI…
1
vote
1 answer

How do print exactly X digits in hex

I have an integer, want to print exactly 6 digits of hex. I tried fprintf(stdout,"%06x\n",number); it does work perfectly when the MSBs are 0, but I use 2's completment for negative numbers, and it doesn't work for them for example. here is what it…
1
vote
2 answers

Expression must be a pointer to a complete object type, why do I get this error in this situation?

This is a simplification of my situation: header.h #DEFINE NUMBER 3 extern char reserved[][]; definer.c char reserved[NUMBER][4] = {"WOW","LOL","K"} sign.c #include "header.h" void theFunctionWithTheError{ if (reserved[1] == "I love…
1
vote
1 answer

Implicit declaration/conflicting types for 'warning' while compiling a basic sample (hoc1) yacc program

I am following the classic Kernighan & Pike The Unix Programming Environment; specifically the chapter that covers yacc. In the first example, a basic calculator named hoc1 is prepared with yacc. Following the book I prepare the following…
M.E.
  • 4,955
  • 4
  • 49
  • 128
1
vote
6 answers

Grab all integers from irregular strings in C

I am looking for a (relatively) simple way to parse a random string and extract all of the integers from it and put them into an Array - this differs from some of the other questions which are similar because my strings have no standard…
RBaxter
  • 13
  • 2
1
vote
1 answer

invalid lvalue in increment error at pointer

after changing GCC version 3.0 to 4.1 i am getting invalid lvalue in increment error #include #include "vscreen_internal.h" extern UDINT colPalette[256]; void memset_f(void *p,USINT value, UDINT len) { register UDINT longValue…
1
vote
1 answer

Problem with downloading data - vertices of square

I would like to write a program in which you give two vertices of the square and the program finds the other two. for example: input: 2 3 4 5 output (3,6) (0,5) But I have a problem when it reads data from the program everything works fine int…
Roundstic
  • 21
  • 3