Questions tagged [c99]

This tag is for questions regarding the International Standard ISO 9899:1999, aka "C99", with technical corrigenda, and for questions about code written in C99 (as opposed to K&R C, C89 or later C Standard revisions like the 2011 revision C11).

This tag is for questions regarding the International Standard ISO 9899:1999 , aka "C99", with technical corrigenda, and for questions about code written in C99 (as opposed to K&R C, C89 or later C Standard revisions like the 2011 revision C11).

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

1900 questions
0
votes
0 answers

Printing output strangeness in C99

I have this C++ code /* Name : paintRoomCalc in C++ Author : Аїӡек Меѥҏ Version : v1.0 License : N/A */ #include #include using namespace std; static void getLayers(float roomWidth, float roomDepth, float roomHeight, float…
0
votes
0 answers

Loop until the correct data type is inputted using C

Objective is to loop until the user inputs an integer and if they input a different data type it will print out an error and then perform the loop again. However when I input a char the loop falls infinitely. How could perform this without the loop…
TecGuy94
  • 49
  • 1
  • 8
0
votes
2 answers

Where does the C standard define the else if statement?

I was just curious about the else if statement in C so I looked at the C99 standard and found nothing. Then I looked at the grammar but again no else if selection_statement : IF '(' expression ')' statement | IF '(' expression ')' statement…
nowox
  • 25,978
  • 39
  • 143
  • 293
0
votes
2 answers

Trying to assign a char pointer from another char pointer. Why is it segfaulting?

Edited: This fixes the original segfault. But now I'm not sure why text2 is just storing NULL char* text = "some text"; char* text2 = malloc(sizeof(text2) * MAX_WORD_LEN); while (*text != '\0'){ *text2++ = *text; …
cdpp
  • 152
  • 2
  • 9
0
votes
1 answer

Implicit declaration of function of a declared prototype

I have this error code: helpers.c:56:13: warning: implicit declaration of function 'swap' is invalid in C99 [-Wimplicit-function-declaration] swap(height, width, image, i, j); ^ helpers.c:62:6: error: conflicting types for 'swap' void swap(int…
Manav Dubey
  • 780
  • 11
  • 26
0
votes
1 answer

How to use boost preprocessor to easier gcc neon inline assesmbly?

While coding gcc neon inline assembler, usually have to write very long clobber if use a lot of registers. How to write a macro to list serials of register in the clobber section? better use boost preprocessor. Thanks. Current method: __asm( "mov…
0
votes
1 answer

Generating initializer-lists using the C preprocessor

I was wondering if it is possible to construct A C99 macro that can either consume this syntax MAGIC(a,b,(c,d),(e,(f,g))) // Expands to {{a}, {b}, {{c, d}}, {{e, {f,g}}}} Or this more functional syntax MAGIC( (a)(b)(c,d)(e,(f,g)) ) // Again should…
Yunus King
  • 1,141
  • 1
  • 11
  • 23
0
votes
1 answer

C99: Custom implementations of non-standard functions

In my project, I want to use a non-standard library function, which which may not be defined on certain systems. In my case, it is strlcpy. From man strcpy: Some systems (the BSDs, Solaris, and others) provide the following function: size_t…
Dosisod
  • 307
  • 2
  • 15
0
votes
2 answers

why is this C union of strings function not working - segfault?

This is a function to find union of strings. #include #include #include #include char* my_union(char* param_1, char* param_2) { char *res[strlen(param_1) + strlen(param_2)]; //allocate long enough…
ERJAN
  • 23,696
  • 23
  • 72
  • 146
0
votes
1 answer

can't concat strings via another string in c

e.g. array = ["abc", "def", "xx"] , concat_string = "-" output: "abc-def-xx" I got "abc-" #include #include #include #ifndef STRUCT_STRING_ARRAY #define STRUCT_STRING_ARRAY typedef struct s_string_array { int…
ERJAN
  • 23,696
  • 23
  • 72
  • 146
0
votes
1 answer

how to print the contents of char**?

I have a structure defined as a char** array containing strings. I dont know how to run printf on its contents. #include #include #include #ifndef STRUCT_STRING_ARRAY #define STRUCT_STRING_ARRAY typedef struct…
ERJAN
  • 23,696
  • 23
  • 72
  • 146
0
votes
0 answers

Automatic enum definition in C99

I would like to create an enum for the states of a DFA. The DFA has 98 states ranging from 0 to 97. The elements of the enum should look like: q_0, q_1, ..., q_97. How to I automatically generate this enum?
0
votes
1 answer

C array/pointer semantics: how to make an array inside a struct to have properties/semantics of corresponding pointer?

Consider this code: void f_01( int a, char** flags ) { printf("flags %p\n", flags); if ( ! flags ) { return; // early exit } //some code } struct s01 { int a; char** flags1; /* NULL = not used */ …
pmor
  • 5,392
  • 4
  • 17
  • 36
0
votes
1 answer

see get min value of nodes, exceptional case

Given the following struct: typedef struct node_t { int x; struct node_t *next; } *Node; Please Note: the definition above is given to me as is and can't be changed. I wrote the following function: inline int getMin(Node *list1,Node…
user13186558
0
votes
0 answers

CLion workaround made bug worse

There's this bug with the placement of certain characters in the embedded terminal in CLion (more thoroughly explained here and here) and there's this workaround, by disabling PTY (Help | Find Action > type "Registry" > open Registry > find and…