c99

Kind of sparse initialization for structures, any resources?

Hi, I used to initialize my structures in this way: struct A a = {0}; This seems to work for me, however I was argued about ANSI C, C89, C99 standard. Simply I couldn't find that in any documentation. Could you help me with that? Here's an example that this works for 'cl' (VS express 2008). #include <stdio.h> struct DATA { i...

Suggestions for concise index handling in circular buffer

I've implemented a circular buffer, and I would like a concise means of updating the buffer pointer while properly handling the wrap-around. Assuming an array of size 10, my first response was something like: size_t ptr = 0; // do some work... p = ++p % 10; Static analysis, as well as gcc -Wall -Wextra, rightly slapped my wrist for...

What is the difference between "Real Types" and "Arithmetic Types" in C?

The C99 standard describes them as so: The integer and real floating types are collectively called real types. Integer and floating types are collectively called arithmetic types. Does this mean they're the same thing in C? Or are there any differences between them? ...

Where can I find a table of all the characters for every C99 Character Set?

I'm looking for a table (or a way to generate one) for every character in each of the following C Character Sets: Basic Character Set Basic Execution Character Set Basic Source Character Set Execution Character Set Extended Character Set Source Character Set C99 mentions all six of these under section 5.2.1. However, I've found it ex...

What is the definition of Incomplete Type and Object Type in C?

What is the definition of Incomplete Type and Object Type in C? Also, could you provide some examples of each? ANSI C99 mentions both type categories in various places, though I've found it difficult to understand what each of them means exactly (there is no paragraph/sentence explicitly defining what they are). ...

What is wrong with using turbo C?

Hi all, I always find that some people (a majority from India) are using turbo C. I cannot find any reason to use such outdated compiler... But I don't know what reasons to give when trying to tell them to use modern compiler(gcc,msvc,...). ...

Choosing the most suitable integer size/range to use for variables

stdint.h in C99 provides many options for integer sizes, types and ranges - so many I don't know what ones to choose! I know how to use size_t and ptrdiff_t when appropriate, and I use fixed size types for storage and transmission. My question concerns values that will only be stored in memory of the host machine. For example, a struct...

In C99, is f()+g() undefined or merely unspecified?

I used to think that in C99, even if the side-effects of functions f and g interfered, and although the expression f() + g() does not contain a sequence point, f and g would contain some, so the behavior would be unspecified: either f() would be called before g(), or g() before f(). I am no longer so sure. What if the compiler inlines t...

size limit of printf conversion specification

printf conversion specifications are % followed by flags, width, precision, length modifier and conversion specifier. Is there practical limit to size of a conversion specification? I.e. %s is 2 chars long, while %08.2f is 6 chars long. My question is, what is the length of the maximal single specification in a format string that can be...

how to get the x to the pow y in C under c99 standard

I have #include<math.h>, and I tried to use pow(x, y) and powf(x, y). but it seems neither of them are under c99 standard. and I use the command gcc -std=c99 test.c -o test to compile. what function there exists I can use? ...

Straight GDI Programming in C on Windows

Hello everyone, I have taken a recent interest in programming as efficiently as possible for Windows in straight C. I still want a GUI for some things, is the Windows API/GDI still the respectable way to go about this? I don't believe you can make regular calls for WPF, since it is largely a managed affair. Is GDI really un-accelerated ...

32 bit Windows and the 2GB file size limit (C with fseek and ftell)

I am attempting to port a small data analysis program from a 64 bit UNIX to a 32 bit Windows XP system (don't ask :)). But now I am having problems with the 2GB file size limit (long not being 64 bit on this platform). I have searched this website and others for possible sollutions but cannot find any that are directly translatable to m...

Getting list of files in a folder using C

Hi I have path to a folder for example /myfolder or in Windows: C:\myfolder and I want to get a list of all files in that folder. How shall I do so in C? Is it different in C++ or C99? How can I get a list of its folders? Any help is appreciated. ...

How to implement `memmove` in standard C without an intermediate copy?

From the man page on my system: void *memmove(void *dst, const void *src, size_t len); DESCRIPTION The memmove() function copies len bytes from string src to string dst. The two strings may overlap; the copy is always done in a non-destructive manner. From the C99 standard: 6.5.8.5 When tw...