Angel
6/14/2011 8:07:00 AM
On 2011-06-13, Robert Bralic <robert.bralic@si.t-com.hr> wrote:
> #include<stdio.h>
>
>
> int main(int argc, char *argv[]){
Since you don't use argc and argv, replace this with:
int main(void) {
> FILE *fp;
> fp=fopen("LPT1:", "w");
You really should check the return value of fopen(). Also, this method
of writing to a printer will likely only work in MS-DOS. It's not gonna
work as expected on any brand of *nix. (You'll just create a file.)
> fprintf(fp,"Hello World");
Again, check the return value for errors. Also, you should add \n to
indicate the line is complete, or it may not be printed.
> return 1;
The standard says that returning a non-zero value from main() indicates
unsuccesful completion to the environment.
To avoid confusion, you might want to use the macros EXIT_SUCCESS and
EXIT_FAILURE (from stdlib.h) for your program exit codes.
--
"C provides a programmer with more than enough rope to hang himself.
C++ provides a firing squad, blindfold and last cigarette."
- seen in comp.lang.c