Strings and C
Working with strings in C requires care with memory and null terminators. Example: implement a simple ciphertext function that shifts characters.
#include <stdio.h>
#include <string.h>
int main(void) {
char s[] = "Hello";
for (int i = 0; i < strlen(s); i++) {
s[i] = s[i] + 1; // naive shift
}
printf("%s\n", s);
}
Practice: implement caesar and vigenere ciphers.