Skip to content
/ sprintfa Public

C function sprintfa uses variable length arrays in C99 to create a buffer from c-stack RAM of exactly the right size and performs an sprintf into that buffer

License

Notifications You must be signed in to change notification settings

skarg/sprintfa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sprintfa

Combine variable length arrays in C99 and sprintf into new function.

The sprintfa function uses variable length arrays in C99 to create a buffer from c-stack RAM of exactly the right size and perform a sprintf into that buffer. This prevents buffer overflows.

To use this function, declare a character which will be the array name as part of the sprintfa() function:

#include "sprintfa.h"

int main(void) {
    char sprintfa(x, "Hello World\n");
    puts(x);

    return 0;
}

Special thanks to Sam for the details.

About

C function sprintfa uses variable length arrays in C99 to create a buffer from c-stack RAM of exactly the right size and performs an sprintf into that buffer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages