Simple C Program for Decrypting a String

This C program defines a function to decrypt a string by decrementing each ASCII character's value by 1. It demonstrates basic string manipulation and use of pointers. The main function initializes a string, calls the decryption function, and outputs the decrypted result.
 avatar
unknown
c_cpp
10 months ago
276 B
7
Indexable
#include <stdio.h>

void decrypt(char str[]) {
    for (int i = 0; str[i] != '\0'; i++) {
        str[i] = str[i] - 1; // Decrement ASCII value by 1
    }
}

int main() {
    char str[] = ")*";
    decrypt(str);
    printf("Decrypted string: %s\n", str);
    
    return 0;
}
Editor is loading...
Leave a Comment