A lightweight, safe, and user-friendly input library for C programming language Scanf Filter Library. Provides robust input validation for integers, floats, doubles, characters, and strings with comprehensive error handling.
ScanFlt-C is a comprehensive input handling library designed to make C programming safer and more user-friendly. It eliminates common issues with standard C input functions like scanf() by providing:
- Automatic input validation
- Buffer overflow protection
- Type-safe conversions
- User-friendly error messages
- Optional prompt system
Whether you're building console applications, educational tools, or production software, ScanFlt-C ensures your input handling is robust and secure.
- Buffer Overflow Protection: Automatic buffer size checking
- Input Validation: Comprehensive type and range checking
- Memory Safety: Safe string handling and pointer validation
- Automatic Retry: Invalid inputs automatically trigger retry prompts
- Error Recovery: Clears input buffer on errors to prevent infinite loops
- Type Conversion: Safe conversion between string and numeric types
- Optional Prompts: All functions support optional message parameters
- Clear Error Messages: Descriptive feedback for invalid inputs
- Empty Input Handling: Proper validation for empty inputs
- Integers: Full
intrange with overflow checking - Floating Points:
floatanddoublewith precision handling - Characters: Single character input with validation
- Strings: Safe string input with buffer size management
- Download the
scanflt.hheader file or click here for direct download. - Place it in your project directory.
- Include it in your C files (make sure use " "):
#include "scanflt.h"| Function | Description | Parameters |
|---|---|---|
| getint() | Read integer input | int* val, const char* msg |
| getfloat() | Read float input | float* val, const char* msg |
| getdouble() | Read double input | double* val, const char* msg |
| getch() | Read single character input | char* val, const char* msg |
| getstr() | Read string input | char* val, const char* msg |
| getstrbuff() | Read string with custom buffer | char* buf, size_t size, const char* msg |
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2025 Mohit Kumar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.```