[For beginners in C language] List of origins of standard functions and names encountered in the early stages of learning

I summarized the origin of the names of standard functions that I encountered when I started learning C language. Knowing the origin will make it easier to remember the function. I'm glad if you can use it as a reference. Also, since this is my first article, I would be grateful if you could point out any points that cannot be reached. I will update it little by little when I feel like it. ^^;

Input / output functions

I thought there were many types. When outputting only one character as standard, use putchar () instead of putc (). When inputting only one character as standard, use getchar () instead of getc (). See here for the differences between putc () and fputc, and getc () and fgetc (). I'm not sure.    https://ja.wikipedia.org/wiki/Getc Also, use getch () (non-standard function) for input that does not use the Enter key.

Output function

Function name Rough function Origin of the name
putchar() Output only one character to standard output put + character
puts() Output string to standard output put + string
printf() Output string to standard output with formatting print + format
fputc() Output only one character to a file file + print + character
putc() Same as above put + character
fputs() Output string to file file + put + string
fprintf() Output string to file with formatting file + print + format

Input function

Function name Rough function Origin of the name
getchar() Input only one character from standard input get + character
gets() Enter a character string from standard input get + string
scanf() Enter a string with formatting from standard input scan + format
fgetc() Enter only one character from the file file + get + character
getc() Same as above get + character
fgets() Enter a string from a file file + get + string
fscanf() Enter a string from a file with formatting file + scan + format

・ The first f is "file" f → Output to file (putc is not included) ・ The f attached at the end is f of "format" → with format (such as% d) ・ C, char → character → character ・ S → string → character string

Functions related to string manipulation

Function name Rough function Origin of the name
sprintf() Assign a string to a formatted array string + print + format
strcpy() Make a copy of the string string + copy
strcat() Add (combine) a string to the end string + catenate
strlen() Find the length of the string string + length
strcmp() Compare strings string + compare
atoi() Convert "character string" representing a numerical value to "numerical value" ASCII + to + integer

-Can be used not only for character strings (strings) but also for arrays in general. -Although there are similar functions such as memcpy (), the str system is personally easier to use.

Recommended Posts