-1

The title maybe a little confusing.. so here is my attempt of explaining it:

I have a command for my program:

c file1.txt > file2.txt

This command in the commandline takes the first file and pipes the output of the program (that is printed) to the second file.

So im scanning a user message in:

printf("Enter a message:");
char *message = malloc(sizeof(char) * 256);
scanf("%s", message);
printf("Your message is: %s", message);

But this prints both printf(...) statements to my piped file, whereas I only want the second one. How can i prevent this?

Thanks!

madcrazydrumma
  • 1,847
  • 3
  • 20
  • 38

1 Answers1

2

One way is to use stderr for the information you don't want copied to the output file:

fprintf(stderr, "Enter a message:");
Klas Lindbäck
  • 33,105
  • 5
  • 57
  • 82