was ist das?
-
was ist das?
strlen(key);
was bringt es und wie setzt man es ein:
hier der code irgendwas ist falsch:
#include <stdio.h> int main() { char key[255],case_type,idx; // Yes, gets() is sloppy, but I don't care, this is just a neccessary step. // When actually using this, you can input the key any way you want. printf("Enter the string: "); gets(key); for (idx=0; idx < strlen(key); idx++) { // Only process alphabetic characters if (key[idx] < 'A' || (key[idx] > 'Z' && key[idx] < 'a') || key[idx] > 'z') continue; // Determine if the char is upper or lower case if (key[idx] >= 'a') case_type = 'a'; else case_type = 'A'; // Rotate the char's value, ensuring it doesn't accidentally "fall off" the end key[idx] = (key[idx] + 13) % (case_type + 26); if (key[idx] < 26) key[idx] += case_type; } printf("String run through ROT-13: "); puts(key); getchar(); return 0; }
-
und gleich dazu warum funktioniert hier das atoi nicht?
gen_keystream(deck,keystream, atoi(key_len));
-
strlen ist eine Funktion aus cstring um die Länge eines null terminierten char-Arrays (C-Strings) herauszufinden:
char str[] = "Super"; size_t len = strlen(str); //gibt 5 zurück
-
imo schrieb:
und gleich dazu warum funktioniert hier das atoi nicht?
gen_keystream(deck,keystream, atoi(key_len));Was funktioniert nicht?
-
Was für einen Typ hat denn key_len? atoi ist dazu da, Strings in Integer-Zahlen umzuwandeln.