What is the difference between printf and fprintf in C?

Asked

Viewed 108 times

1

My question is as simple as this: What is the difference between printf and fprintf in C?

I saw answers for Java, but since I don’t know anything about Java I don’t know if it has to do with.

For example, in the code snippet below, a printf and a fprintf appear:

switch (opt) {

        case 's':
            saida=optarg;
            printf("Nome do arquivo de saida: %s\n", saida);
            errS++;
            break;

        case 'e':
            entrada=optarg;
            printf("Nome do arquivo de entrada: %s\n", entrada);
            errE++;
            break;


        case '?':
            fprintf(stderr, "\nFALTA PARAMETROS\n");

        default:
            fprintf(stderr, "%s \nparametros:\n-e arquivo de entrada\n-s arquivo de saida\n", argv[0]);
            exit(EXIT_FAILURE);
    }
  • Thanks for the direction, when I researched I did not find the topic quoted.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.