Questions tagged [c89]

This tag is for questions regarding the international standard ISO 9899:1990, also known as "C89", "C90" or "ANSI C", with amendments and technical corrigenda (as opposed to K&R C, C99, C11 or later C standard revisions).

The first C standard was released 1989 nationally in USA, by their national standard institute ANSI. This release is called C89 or ANSI-C. One year later, the American standard was accepted internationally and published by ISO (ISO 9899:1990). This release is called C90. Technically, it is the same standard as C89/ANSI-C, though formally, C90 replaced C89/ANSI-C, making them obsolete.

Always use the tag for all your C questions, then complement it with the tag for questions that are specific to this version of the standard.

643 questions
0
votes
1 answer

Is it possible to test for two new line characters in a row?

I'm trying to validate lines in a file with actual content in them, and exiting on cases where there are two empty lines in a row. Can this be done? This code results in fgetc() not catching the double carriage returns/new lines. Code is a snippet…
user2470057
  • 529
  • 4
  • 17
0
votes
1 answer

Segfault when accessing a structure's member

I'm confronted to a strange problem, my program has a segfault when i try to access a structure member but my structure's address is not NULL and I've never freed this structure. The structure's address is something like "0x8000000000" or…
Ziad
  • 419
  • 3
  • 7
  • 15
0
votes
1 answer

Doubts in K&R edition 2

1. 8.2 Page 171 Low Level I/O - Read and Write #include "syscalls.h" int getchar(void) { char c; return (read(0, &c, 1) == 1) ? (unsigned char) c : EOF; } Casting c to unsigned char in the return…
rootkea
  • 1,474
  • 2
  • 12
  • 32
0
votes
0 answers

ANSI C fopen() mode choice

I’m working on a project and I’m in doubt which one of FILE *ptr_file; ptr_file = fopen("input.txt", "ab+"); or FILE *ptr_file; ptr_file = fopen("input.txt", "wb+"); fits the requirements better. If the file does not exist already, it is created;…
TheUnknown
  • 53
  • 2
  • 10
0
votes
1 answer

"Add" function in linked list

I got declaration of linked list: typedef struct element *P_element; typedef struct element { char *value; P_element next; } ELEM; P_element L = NULL; and I have to create function add with this header: void Add (P_element…
Sk1X1
  • 1,305
  • 5
  • 22
  • 50
0
votes
1 answer

Reading a grid from a text file and storing it within a two-dimensional array?

Suppose you had a file called "input.txt" that looked like this: 5 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 A 5 x 5 grid above. And you wanted to store the 5 x 5 grid into a two-dimensional C array. My issue is reading the file into…
Jebathon
  • 4,310
  • 14
  • 57
  • 108
0
votes
2 answers

Any way to create a char of size 32 in ANSI c?

I know C++11 has a type char32_t that is 4 bytes, and I'm wondering if it's possible to implement something similar in C. The program I'm writing needs to have all char arrays be a multiple of 4 bytes.
0
votes
2 answers

warning: initializer element is not computable at load time

I fail to understand gcc -pedantic output in the following scenario: $ gcc -pedantic parse.c -lpopt parse.c: In function ‘main’: parse.c:19:7: warning: initializer element is not computable at load time { "bps", 'b', POPT_ARG_INT, &speed, 0, …
malat
  • 12,152
  • 13
  • 89
  • 158
0
votes
1 answer

Script for file loading doesn't work because of a misterious reason

A function that reads file streams and prints them on-screen invokes undefined behavior and I am unable to localize the cause. This works if file, that contains less then two lines is loaded, otherwise it crashes. #include #include…
Alan Salios
  • 241
  • 2
  • 9
0
votes
4 answers

Good way for declaration of loop variable in pure C (pre C99)?

As you know in C you can't declare the loop variable in the initialization of the for loop as opposed to C++. What is the proficient/ good style way to declare a loop variable in pure C? Is it better to be global? int i = 0; for (i = 0; fmla[i]…
AlexRu
  • 85
  • 1
  • 8
0
votes
3 answers

Structures and functions in C

I am getting errors in the following code. The errors disappear if I take out "struct point p2...". p1 is assembled the same way and works fine, what is the catch here? #include struct point { int x; int y; }; struct point…
kits
  • 609
  • 6
  • 20
0
votes
0 answers

Is it possible to cross-compile adb for old c89 compiler arm-linux-gcc --version 2.95.2?

I want to compile adb with an old arm compiler: arm-linux-gcc --version 2.95.2 But adb sources seem to be c99 and it seems this compiler only wants c89. Would it be impossible to compile adb somehow anyway? Compiling an old version of adb or moving…
JohnyTex
  • 3,323
  • 5
  • 29
  • 52
0
votes
1 answer

OpenWrt LibUbi implementation

i'm trying to develop an application (written in ANSI C) for an OpenWrt router using libuci. I've read this useful post: How to find out if the eth0 mode is static or dhcp? and i've develop a piece of my application that is able to read network data…
user2914917
  • 33
  • 2
  • 5
0
votes
2 answers

C89: Multithreaded Random Values with rand_r()

So, I was curious how someone could get random values across multiple threads with the rand_r command. If I used time(NULL) for the seed everyone ends up with the sam seed because the threads are created so close together. There actions are all…
guitar80
  • 716
  • 6
  • 19
0
votes
2 answers

C89 - error: expected ')' before '*' token

I am getting this error within C. error: expected ')' before '*' token But cannot trace it. void print_struct(struct_alias *s) //error within this line { ... } //end of print method My question is when receiving this error where can the error…
Jebathon
  • 4,310
  • 14
  • 57
  • 108