I am trying to make a C program about a Nuclear Missile launch. Below is my source code so far:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int nukeLaunchCode = 618243;
int NLC_input;
char *address;
int main(void) {
address = malloc(sizeof(char) * 60);
printf("\033[0;34m[INFO] C.E.R.B.E.R.U.S Activating");
fflush(stdout);
for (int i = 0; i < 3; i++){
printf(".");
sleep(1);
}
fflush(stdout);
printf("\n");
printf("\033[0;32m[INFO] C.E.R.B.E.R.U.S Initialized. Enter destination for nuke in address form: ");
fgets(address, 60, stdin);
printf("\033[0;32m[INFO] Geo locating address via Advanced UAV");
fflush(stdout);
for (int i = 0; i < 6; i++) {
printf(".");
fflush(stdout);
sleep(1);
}
printf("\n");
fflush(stdout);
printf("\033[0;31m[WARNING] Target Acquired. Enter 6-digit Nuke Confirmation code to proceed: ");
fgets(&NLC_input, 7, stdin);
return 0;
}
The problem is the fgets at the end of the code. I get a warning saying:
Incompatible pointer types passing 'int *' to parameter of type 'char *'
I've tried using scanf wiht the "%d"
conversion symbol and then I get another warning saying:
'scanf' used to convert a string to an integer value, but function will not
report conversion errors; consider using 'strtol' instead
Can someone please tell me what I'm doing wrong? Also, I've included the fflush functions because i was trying to do something cool. I wanted to print a certain amount of dots every second after a sentence was printed to animate a loading kind of thing. For some reason, without the fflush functions, commands are executed out of order and the dots don't print. But even with the fflush functions, the first line that's printed doesn't print the 3 dots until the next line is printed. I'm pretty sure this is a misplacement in the fflush functions, but can someone help me with that too please? Thank you!