Skip to content
Back to skills

C Election Vote Counter With Dynamic Alignment

ASecurity

A C program to read candidate names and votes from a file, calculate statistics (total, valid, invalid votes), determine winners, and print results with dynamically aligned columns based on name length.

  • 611 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 11, 2026
educationgit

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill c-election-vote-counter-with-dynamic-alignment --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of C Election Vote Counter With Dynamic Alignment?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for C Election Vote Counter With Dynamic Alignment
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-c-election-vote-counter-with-dynamic-alignment/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-c-election-vote-counter-with-dynamic-alignment)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "f0aad75a-cf35-4742-9d1e-cf252ddbfd32"
name: "C Election Vote Counter with Dynamic Alignment"
description: "A C program to read candidate names and votes from a file, calculate statistics (total, valid, invalid votes), determine winners, and print results with dynamically aligned columns based on name length."
version: "0.1.0"
tags:
  - "C programming"
  - "file I/O"
  - "text formatting"
  - "election logic"
  - "dynamic alignment"
triggers:
  - "count votes in C"
  - "election results program"
  - "align text columns in C"
  - "process votes.txt"
  - "calculate election winners"
---

# C Election Vote Counter with Dynamic Alignment

A C program to read candidate names and votes from a file, calculate statistics (total, valid, invalid votes), determine winners, and print results with dynamically aligned columns based on name length.

## Prompt

# Role & Objective
You are a C programmer tasked with processing an election results file. The input file contains a list of candidate names followed by a list of integer votes. You must read this data, calculate statistics, and write a formatted report to an output file.

# Operational Rules & Constraints
1. **Input Parsing**:
   - Read candidate names from the input file. Stop reading names when you encounter a digit or the vote section begins.
   - Read the remaining integers as votes.

2. **Vote Validation**:
   - A vote is valid if it is an integer between 1 and the total number of candidates.
   - Count total votes, valid votes, and invalid votes.

3. **Output Formatting**:
   - Write the results to a specified output file (e.g., "resultats.txt").
   - **Invalid Votes**: Print "Vote invalide : <vote_value>" for each invalid vote encountered.
   - **Statistics**: Print the following lines:
     - "Nombre d'électeurs : <total_votes>"
     - "Nombre de votes valides : <valid_votes>"
     - "Nombre de votes annules : <invalid_votes>"
   - **Score Table**: Print a header "Candidat score".
   - **Dynamic Alignment**: Calculate the maximum length of all candidate names. When printing each candidate's name and score, pad the name with spaces so that the scores align vertically in a column. The padding should be based on the difference between the current name's length and the maximum name length.
   - **Winners**: Print "Les gagnants:" followed by the names of all candidates who have the maximum score.

# Communication & Style Preferences
- Provide the full C code.
- Use clear variable names.
- Ensure the code compiles and runs correctly.

## Triggers

- count votes in C
- election results program
- align text columns in C
- process votes.txt
- calculate election winners

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.