A single-header, simple, customizable progress bar library for C programs. Create beautiful command-line progress indicators with minimal setup.
- 🚀 Easy to use API
- 🎨 Customizable appearance
- 📊 Optional percentage display
- 🔢 Optional count display
- 🎯 Custom format strings
- ⚡ Live updates
- 🎁 Portable - just copy one header file
- 💡 No external dependencies
Simply include the header file in your project:
#define PROGRESS_BAR_C_IMPLEMENTATION
#include "progress-bar-c.h"
// Do this ONCE in C/C++ file
#define PROGRESS_BAR_C_IMPLEMENTATION
#include "progress-bar-c.h"
int main() {
// Create a progress bar with '#' as fill symbol, 20 chars length, total of 100 steps
ProgressBar pb = init('#', 20, 100);
for(int i = 0; i <= 100; i++) {
update(&pb, i); // Update progress
// or use tick() function
// tick(&pb);
print(pb); // Display progress bar
// Do some work...
}
return 0;
}
ProgressBar init(char symbol, int length, int total)
symbol
: Character used to fill the progress barlength
: Width of the progress bar in characterstotal
: Total number of steps
ProgressBar update(ProgressBar *pb, int progress) // Update progress value
ProgressBar tick(ProgressBar *pb) // Increment progress by 1
void print(ProgressBar pb) // Display the progress bar
ProgressBar showPercent(ProgressBar *pb, bool show) // Toggle percentage display
ProgressBar showCount(ProgressBar *pb, bool show) // Toggle count display
ProgressBar setStartEndSymbols(ProgressBar *pb, char start, char end) // Set custom brackets
ProgressBar setCustomFormat(ProgressBar *pb, char* format) // Set custom format string
ProgressBar setCompletedText(ProgressBar *pb, char* text) // Set text showed when progress is completed
ProgressBar setSymbol(ProgressBar *pb, char symbol) // Set symbol for filling progress bar
bool getShowPercent(ProgressBar *pb) // Get percentage display
bool getShowCount(ProgressBar *pb,) // Get count display
char getStartSymbol(ProgressBar *pb) // Get start symbol
char getEndSymbol(ProgressBar *pb) // Get end symbol
char* setCustomFormat(ProgressBar *pb) // Get custom format string
char* setCompletedText(ProgressBar *pb)// Get text showed when progress is completed
char getSymbol(ProgressBar *pb) // Get symbol for filling progress bar
The format string can include:
{bar}
- The progress bar itself{percent}
- Percentage complete (if enabled){count}
- Progress count (if enabled)
Example format: "Progress: {bar} | {percent} Complete ({count})"
ProgressBar pb = init('#', 20, 100);
update(&pb, 50);
print(pb);
// Output: [########## ]
ProgressBar pb = init('=', 25, 75);
showPercent(&pb, true);
showCount(&pb, true);
update(&pb, 30);
print(pb);
// Output: [========= ] 40% (30/75)
ProgressBar pb = init('>', 30, 50);
setCustomFormat(&pb, "Loading... {bar} {percent}");
showPercent(&pb, true);
update(&pb, 25);
print(pb);
// Output: Loading... [>>>>>>> ] 50%
ProgressBar pb = init('=', 20, 100);
setStartEndSymbols(&pb, '<', '>');
update(&pb, 75);
print(pb);
// Output: <=============== >
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Follow C89/C90 standard for maximum compatibility
- Maintain consistent code style
- Add tests for new features
- Update documentation for API changes
- Keep the library dependency-free
This project is licensed under the MIT License - see the LICENSE file for details.
ANKDDEV - GitHub Profile