I want to get my program to use the command line arguments with getchar to then encode a message. My problem is that getchar is only paying attention to what I type after the program has executed. How can I make it read the command line arguments instead?
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int pin, charin, charout;
// this verifies that a key was given at for the first argument
if (atoi(argv[1]) == 0){
printf("ERROR, no key was found..");
return 0;
}
else {
srand(atoi(argv[1]));
pin = rand() % 27;
}
while( (charin=getchar()) != EOF){
charout = charin + pin;
putchar(charout);
}
}