Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,166 questions

40,722 answers

573 users

How to print to stderr in C

2 Answers

0 votes
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[]){

    if (argc != 2) {
        fprintf(stderr, "ERROR: No program arguments\n");
        exit(EXIT_FAILURE);
    }

    return(0);
}





/*
run:

ERROR: No program arguments

*/

 





answered May 4, 2021 by avibootz
0 votes
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[]){

    if (argc != 2) {
        fwrite("ERROR: No program arguments\n", 32, 1, stderr);
        exit(EXIT_FAILURE);
    }

    return(0);
}





/*
run:

ERROR: No program arguments

*/

 





answered May 4, 2021 by avibootz

Related questions

1 answer 95 views
2 answers 73 views
73 views asked Apr 10, 2021 by avibootz
1 answer 12 views
1 answer 18 views
...