Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Posts tagged c

13 child tags

Use this tag for questions concerning use of the C programming language and for questions containing code in the C language. Avoid using it together with the C++ tag unless your question is explicitly about code compatibility or differences between C and C++.

Unless the question explicitly mentions which version of the C standard that is uses, the current active version of ISO 9899 is assumed (C17/C18).

When applicable, always include information about which compiler and target system you are using.
Tag Wiki

The C language is a general-purpose programming language developed by Dennis Ritche at Bell Labs in the early 1970s. The original purpose was kernel- and application programming for the UNIX operative system, which is why many of the standard functions and libraries in C originate from UNIX.

In the 70s and 80s, there was no formal standardization of C. The closest thing to a canonical source was the book The C Programming Language, written by Brian Kernighan and Dennis Ritchie. The book is referred to as "K&R" (Kernighan & Ritchie) and everything before standardization is therefore usually called "K&R C".

The first standardization of the language was carried out in USA, by ANSI in the year 1989. This first version is therefore widely known as "ANSI C". One year later in 1990, the ANSI standard was adopted internationally by ISO, why this version of the language is also often called "C90". Technically, "ANSI C", "C89" and "C90" are identical.

The language standard has since then been revised several times:

  • a minor revision in 1995 ("C95")
  • a major revision in 1999 ("C99")
  • a major revision in 2011 ("C11")
  • a minor revision in 2017 ("C17" or "C18", since it was released by the committee in 2017 but published by ISO in 2018).

These revisions are typically backwards compatible, but modern C code will not run on older compilers. C17 is the current standard. The C language is technically owned by ISO and it is maintained by the ISO committee JTC1/SC22/WG14.

The formal name for the standard is ISO/IEC 9899 - Information technology - Programming languages - C. Draft versions of the C standard are usually available free of charge, such as draft N1548 of C11.

75%
+4 −0
Q&A How to clear the contents of a file?

How to clear the contents of a file using C?

1 answer  ·  posted 2y ago by dumplings‭  ·  edited 2y ago by hkotsubo‭

Question c file-handling
28%
+0 −3
Q&A Data structure implementation with Linked lists.

Could someone explain this part of the coding for data structures & linked list? I actually got this code from a textbook but no matter how I read the textbook, I still don't get the concept &a...

1 answer  ·  posted 2y ago by hamburgersarecool‭  ·  last activity 2y ago by Alexei‭

37%
+1 −3
Q&A How can I delete a book from the collection by a particular title from my library file?

I would like to delete a book from the collection by a particular title from my library if the user enters 2 as input for my switch statement. How can I do that with my current code? #include<...

0 answers  ·  posted 2y ago by hamburgersarecool‭  ·  edited 2y ago by hamburgersarecool‭

50%
+2 −2
Q&A How can you modify your server code to make it accept any port numbers instead of just one which is the one you predefined?

Is there any way where I can modify the original server code so that it accepts any port number instead of the predefined one (i.e., port number 8989)? Port number will be entered in the command li...

0 answers  ·  posted 2y ago by hamburgersarecool‭  ·  edited 2y ago by Alexei‭

Question c sockets port winsock2
25%
+0 −4
Q&A What does the greater than 0 indicate in the case of this statement 'if (compare(A[j], A[j+1]) > 0)' ? Thank you.

Question: There is a list of integers in an array (3,2,1,5,6,4), sort this list in both ASCENDING & DESCENDING order. Create a sort function. #include<stdio.h> #include<stdlib.h> ...

1 answer  ·  posted 2y ago by dumplings‭  ·  last activity 2y ago by Lundin‭

66%
+4 −1
Q&A Invalid memory access when trying to dereference a pointer obtained through a function call

Hey, regarding a question on returning pointers as functions, why does my code produce this error & won't print out the sum = 6? #include<stdio.h> #include<stdlib.h> int *A...

1 answer  ·  posted 2y ago by dumplings‭  ·  last activity 2y ago by celtschk‭

77%
+5 −0
Q&A Common string handling pitfalls in C programming

Preface: This is a self-answered Q&A meant as a C string handling FAQ. It will ask several question at once which isn't ideal, but they are all closely related and I'd rather not fragment the p...

1 answer  ·  posted 2y ago by Lundin‭  ·  last activity 2y ago by Lundin‭

90%
+18 −0
Q&A What must a C compiler do when it finds an error?

What exactly must a C compiler do when it finds a compile-time error? The most obvious kind of errors are language syntax errors, but the C standard also speaks of constraints, which are rules tha...

1 answer  ·  posted 3y ago by Lundin‭  ·  edited 2y ago by ghost-in-the-zsh‭

87%
+12 −0
Q&A What compiler options are recommended for beginners learning C?

When reading questions about C programming from beginners, I very often see them describing peculiar run-time errors and crashes, segmentation faults and similar. They have spent a lot of time chas...

1 answer  ·  posted 3y ago by Lundin‭  ·  edited 2y ago by Lundin‭

42%
+1 −2
Q&A How do I filter an array in C?

No, I'm not trying to get the full program written completely in C by you guys. I only need some way to implement the functionalities of each function I found confusing. In this challenge in Code ...

2 answers  ·  posted 2y ago by General Sebast1an‭  ·  last activity 2y ago by Derek Elkins‭

Question c javascript array
75%
+4 −0
Code Reviews Counting number of assignments that a `fscanf` format strings implies

I'm writing a function that counts the number of assignments for a fscanf format string. I studied the documentation in C standard 7.21.6.2 It looks like it works. It passes all test cases I have w...

3 answers  ·  posted 3y ago by klutt‭  ·  last activity 2y ago by klutt‭

37%
+1 −3
Q&A Why does this code that uses a pointer-to-pointer-to-int segfault?

Hello folks, can someone resolve this seg fault with me please, i can't find the error where it occur. Thank you. #include <stdlib.h> #include <stdio.h> int ft_ultimate_range(int *...

1 answer  ·  posted 3y ago by M3dc0d‭  ·  last activity 3y ago by Lundin‭

62%
+3 −1
Q&A Reading contents of XML node

I'm writing some functions in C that parses a part of a XML file (using libxml), but instead of extracting the content of the XML node that has a specific name, it outputs a string that's not in UT...

0 answers  ·  posted 3y ago by southernisles‭  ·  edited 3y ago by Alexei‭

66%
+4 −1
Code Reviews BMPL: The language I'll bring to life

Last year, I started working on a language I named SuperCode but then decided BMPL (Builder's Multi-Purpose Language) as the final name. The language would be written using C and up until now, the ...

1 answer  ·  posted 3y ago by General Sebast1an‭  ·  last activity 3y ago by Lundin‭

71%
+3 −0
Q&A Why use an asterisk after a type?

#include<stdio.h> struct Node{ int data; struct Node* next; }; Here I used an asterisk after Node. What is it used for? What if I don't put any asterisk after Node (both Node...

2 answers  ·  posted 3y ago by deleted user  ·  edited 3y ago by hkotsubo‭

Question c pointers
50%
+1 −1
Q&A Input taking only first character of a string

I wrote a program named Kernel.c 2 months into my life in programming and created 4 functions at the time, and now there are 7 functions. Recently, I updated the program completely onto an online ...

1 answer  ·  posted 3y ago by General Sebast1an‭  ·  last activity 3y ago by elgonzo‭

Question c string input
77%
+5 −0
Q&A Warn of implicit cast in a function's arguments with GCC?

In the C program below, I make a mistake and call the function with (ld, ld) instead of (d, ld). #include <stdio.h> #include <limits.h> void print_int_long(int n, long l){ pri...

2 answers  ·  posted 3y ago by Quasímodo‭  ·  last activity 3y ago by Lundin‭

83%
+8 −0
Q&A Is `uint8_t` always an alias for a character type if it exists?

Is uint8_t guaranteed to be a character type if it exists? Will using a uint8_t* to examine bytes of an object cause violation of the strict aliasing rule? Is the following legal code: #include &l...

1 answer  ·  posted 3y ago by Ayxan Haqverdili‭  ·  edited 3y ago by Lundin‭

82%
+12 −1
Q&A What is the difference between operator precedence and order of evaluation?

When doing something simple such as this int a=1; int b=2; int c=3; printf("%d\n", a + b * c); then I was told that operator precedence guarantees that the code is equivalent to a + (b * c)...

1 answer  ·  posted 3y ago by Lundin‭  ·  edited 3y ago by Lundin‭

81%
+7 −0
Q&A .elf file - What contributes to the resulting .bin file size?

I have found this nice library for parsing/writing .elf files as output by e.g. the GCC toolchain: ELFIO I have a bare metal embedded project with an ARM Cortex M target. My goal is to overwrite...

0 answers  ·  posted 3y ago by sktpin‭  ·  edited 3y ago by sktpin‭

Question c elf linker
62%
+3 −1
Q&A What's the difference between null pointers and NULL?

Someone told me that I shouldn't write "NULL pointer" with capital letters, because a null pointer and NULL are different terms. And that NULL is a "null pointer constant". What's the meaning of th...

3 answers  ·  posted 3y ago by Lundin‭  ·  last activity 3y ago by EJP‭

83%
+8 −0
Q&A Is MISRA-C useful outside safety-critical and embedded programming?

When discussing best or safest C programming practices with various C gurus on the Internet, the "MISRA-C guidelines for the use of C language in critical systems" often pops up as a source. This ...

1 answer  ·  posted 3y ago by Lundin‭  ·  last activity 3y ago by ghost-in-the-zsh‭

Question c misra-c
81%
+7 −0
Q&A Why can't we mix increment operators like i++ with other operators?

I'm experimenting with different operators and have a hard time understanding the outcome of certain expressions. I try to combine the ++ operators with other operators such as assignment in the sa...

1 answer  ·  posted 3y ago by Lundin‭  ·  last activity 3y ago by Lundin‭

83%
+8 −0
Q&A Should I cast to (void) when I do not use the return value

I saw at least one compiler (Codewarrior for HC12) warn me if I use a function without using it's return value. Other compilers (clang/gcc) do not issue a warning though, even when using the std=90...

3 answers  ·  posted 3y ago by Kami‭  ·  edited 3y ago by Monica Cellio‭

75%
+4 −0
Q&A Generate SIGSEGV without undefined behaviour.

In order to test that coredumps are generated and that they contain useful information which can be retreived with gdb I need to generate a SIGSEGV. Or anything else which causes a coredump. The co...

1 answer  ·  posted 3y ago by Estela‭  ·  last activity 3y ago by Lundin‭

Question c++ linux gcc
86%
+11 −0
Q&A What is undefined behavior and how does it work?

I have created this sensational program: #include <stdio.h> int* func (void) { int local=5; return &local; } int main (void) { printf("%d\n", *func()); } This prints 5 even thoug...

1 answer  ·  posted 3y ago by Lundin‭  ·  last activity 3y ago by Lundin‭

80%
+6 −0
Q&A Is it undefined behaviour to just make a pointer point outside boundaries of an array without dereferencing it?

I have heard that it is undefined behaviour to make a pointer point outside boundaries of an array even without dereferencing it. Can that really be true? Consider this code: int main(void) { ...

2 answers  ·  posted 3y ago by klutt‭  ·  last activity 3y ago by hkotsubo‭