cmanuals

A simple custom manual to the functions and methods in the ISO C99 programming language.

View on GitHub
printf - cmanuals

printf - Prints out to stdin
fprintf - Prints out to a FILE *
sprintf - Prints out to a const char *

dprintf, snprintf, vprintf, vfprintf, vsprintf, vdprintf, vsnprintf

<< BACK

SYNOPSIS

Prototype - Simple

int printf(char *format, args*);
Note that args* means zero or more arguments. (not to do with ISO C99)
Think of char * as a string.

Prototype - Experienced

int printf(const char *restrict format, ...);
int fprintf(FILE *restrict format, ...);
int sprintf(char *restrict src, const char *restrict format, ...);
int dprintf(int fd, const char *restrict format, ...);
int snprintf(char str[restrict .size], size_t size, const char *restrict format, ...);
int vprintf(const char *restrict format, va_list ap);
...

Note that ... means zero or more arguments. (not to do with ISO C99)

EXAMPLES

printf

                    #include <stdio.h>

typedef const char* string;
int main(void)
{
string s = "cmanuals is cool!";
printf("%s", s); // Prints out "cmanuals is cool" to the screen

int i = 10;
printf("cmanuals is really %i/%i!", i); // Prints out "cmanuals is really 10/10!" to the screen

double d = 3.14159265358979;
printf("pi is %.14lf.", d); // Prints out "pi is 3.14159265358979" to the screen
}

fprintf

                    #include <stdio.h>

                    int main(void)
                    {
                        FILE *file = fopen("hellofile.txt", "w");
                        if (file == NULL)
                        {
                            return 1;
                        }

                        char *s = "Hello, file";
                        fprintf(file, "%s\n", s);
                    }
                

sprintf

                    #include <stdio.h>

                    int main(void)
                    {
                        char buf[32];

                        double pi = 3.14159265358979;
                        sprintf(buf, "%lf", pi);
                    }