C / ANSI-C examples (example source code) Organized by topic





stdio.h /

clearerr 1fclose 1feof 1ferror 1
fflush 1fgetc 1fgetpos 1fgets 1
fopen 2fprintf 1fputc 1fputs 1
fread 1freopen 1fscanf 1fseek 1
fsetpos 1ftell 1fwrite 1getc 1
getchar 1gets 1perror 1printf 39
putc 1putchar 1puts 1remove 1
rename 1rewind 1scanf 2setbuf 1
setvbuf 1snprintf 1sprintf 1sscanf 1
tmpfile 1tmpnam 1ungetc 1

stdlib.h /

abort 1abs 1atexit 1atof 1
atoi 1atol 1atoll 1bsearch 1
calloc 1div 1Exit 2 1exit 1
free 1getenv 1labs 1ldiv 1
llabs 1lldiv 1malloc 1mblen 1
mbstowcs 1mbtowc 1qsort 1rand 1
realloc 1srand 1strtod 1strtof 1
strtold 1strtoll 1strtoul 1strtoull 1
system 1wcstombs 1

string.h /

memchr 1memcmp 1memcpy 1memmove 1
memset 1strcat 1strchr 1strcmp 1
strcoll 1strcpy 1strcspn 1strerror 2
strlen 1strncat 1strncmp 1strncpy 1
strpbrk 1strrchr 1strspn 1strstr 1
strxfrm 1

math.h /

acos 1acosh 1asin 1asinh 1
atan 1atan2 1atanh 1cbrt 1
ceil 1copysign 1cos 1cosh 1
erf 1erfc 1exp 1exp2 1
expm1 1fabs 1fdim 1floor 1
fma 1fmax 1fmin 1fmod 1
fpclassify 1frexp 1hypot 1ilogb 1
isfinite 1isgreater 1isgreaterequal 1isinf 1
isless 1islessequal 1islessgreater 1isnan 1
isnormal 1isunordered 1ldexp 1lgamma 1
llrint 1llround 1log 1log10 1
log1p 1log2 1logb 1lrint 1
lround 1modf 1nan 1nearbyint 1
nextafter 1nexttoward 1pow 1remainder 1
remquo 1rint 1round 1scalbln 1
scalbn 1signbit 1sin 1sinh 1
sqrt 1strftime 1tan 1tanh 1
tgamma 1time 1trunc 1

ctype.h /

isalnum 1isalpha 1isblank 1iscntrl 1
isdigit 1isgraph 1islower 1isprint 1
ispunct 1isspace 1isupper 1isxdigit 1
tolower 1toupper 1

time.h /

asctime 1clock 1ctime 1difftime 1
gmtime 1localeconv 1localtime 1mktime 1
setlocale 1tm 1

assert.h /

assert 1

wctype.h /

iswalnum 1iswalpha 1iswblank 1iswcntrl 1
iswdigit 1iswgraph 1iswlower 1iswprint 1
iswpunct 1iswspace 1iswupper 1iswxdigit 1
towlower 1

signal.h /

raise 1

setjmp.h /

longjmp 1setjmp 1

Data Type /

Array Char 15Array Double 3Array Float 1Array Int 16
Array String 1Array Two Dimension 14Binary Display 1Bit AND 1
Bit OR 1Bit Reverse 1Bit Shift 4Bitwise XOR 3
Char Validation 14Char 12Constant 4Control Character 7
Decimal 1Define New Type 1Double 7Enum 5
Float 14Hex 4Int Convert 4Int 19
Long 6Register 2Short 1Static 5
Union 2

Pointer /

Pointer Array 6Pointer Char 10Pointer Double 2Pointer Int 14
Pointer Long 1Pointer Pointer 2Pointer String 2

String /

String Append 9String Case 2String Compare 6String Convert 16
String Copy 6String General 17String Length 11String Search 15
String Split 4

Data Structure Algorithm /

Bubble Sort 3Insertion Sort 1Link List 1Queue 2
Quick sort 8Search 2Selection Sort 1Shaker Sort 1
Shell Sort 1Stack 2Tree 4

Console /

Console Input Validation 1Console Menu 1Console Output Char 4Console Output float 1
Console Output Int 5Console Output String 8Console Output 2Console Read Any 2
Console Read Char 7Console Read Decimal 1Console Read Int 6Console Read String 6
Console Read Validation 8Formatted Output Float 5Formatted Output Hex 1Formatted Output Int 6
Formatted Output String 1Printf 6Scanf 5

Language Basics /

Comments 2Do While 7Extern 1For Break 5
For Continue 2For 31Goto 1If 20
Main 7Operator General 14Operator Rank 1Operator Relation 3
Operator Self Increase 3Operator Ternary 7Statement 1Switch 11
Variable Scope 14Variable 4While 4

Development /

Assert 1Bar Chart 1Beep 2Command Line Parameters 10
Compile Info 1Debug 3Environment 1error 6
Exit Abort 4Locale 2Print 1System Command 2
Table 1Time Date 21Timer 2

Structure /

Struct Define 8Struct Size 2Structure Array 4Structure Parameters 1
Structure Serialization 2

Memory /

Memory Allocation 10Memory Compare 2Memory Copy 2Memory Free 1
Memory Jump 1Memory Move 2Memory Save 1Memory Search 1
Memory Set 2

Math /

Absolute Value 4Cos ACos 6Divide 5Exp 4
Log 4Mod 5Power 3Random 10
Round 2Sin ASin 8Square Root 2Tan ATan 8

File /

Binary File 1File Close 1File Compare 1File Content Search 5
File Copy 3File Delete 4File End 4File Error 1
File fprintf fscanf 2File fwrite fread 1File Open 6File Pointer 4
File Read 16File Rename 2File Temp 3File Write 20
Stream Buffer 1

Macro Preprocessor /

if def 4ifndef 1Inline 1Line 1
Macro Basic 3Macro Constant 10Macro Function 10Macro String 3
Preprocessor IF 3Preprocessor LINE 1Preprocessor 1

Function /

Function Parameters 21Function Pointer 10Function Recursive 7Function 31

Small Application /

Calculator 2