Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ctrl+D doesn't stop application from executing in command window

Tags:

c

I've written a program to encrypt a given message by XOR. It works, but It doesn't end. Here is the code.(I have created 3 files):

encrypt.h :

void encrypt(char *message);

message_hider.c:

#include <stdio.h>
#include "encrypt.h"

int main() {
  char msg[80];

  while (fgets(msg, 80, stdin)){
    encrypt(msg);
    printf("%s", msg);
  }

  return 0;
}

encrypt.c :

#include "encrypt.h"

void encrypt(char *message) {
  while (*message) {
    *message++ ^= 0x1f;
  }
}

As I mentioned above, It works. but I can't stop it. When I pressed Ctrl+D to stop it (in cmd) It encrypts it also.(I need this code stop after it encrypt a message). Please explain me about this case.

like image 252
0xEDD1E Avatar asked Dec 21 '25 11:12

0xEDD1E


1 Answers

When I pressed Ctrl+D to stop it (in cmd)

If that's the cmd from Windows you probably want Ctrl+Z.

like image 106
cnicutar Avatar answered Dec 23 '25 04:12

cnicutar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!