Debug mode in SHELL scripts
Posted December 17, 2008
on:To run a shell script in DEBUG mode, put “-x” option at the end of the interpreter in the first line.
#!/usr/local/bin/sh –x
This is going to print the steps the compiler goes through.
- In: C/CPP
- Leave a Comment
The “default” case in a switch case need not be perfect by its spelling. If none of the cases satisfy the condition, the compiler will search for “default” case. If its there, it’ll execute that block. In case you have miss spelled it [may be in hurry! ;)], the compiler won’t give any error, but it won’t go for that block as it is not “default” block.
So be careful while using switch statement.
Standard Output in C
Posted December 17, 2008
on:- In: C/CPP
- Leave a Comment
“stdout” flushes the data to be printed to standard output device only after getting an new line character. If it wont get a new line character, it waits until the program ends, then it flushes the data.
Ex:
Code:
#include<stdio.h>
int main()
{
fprintf(stdout,”hello-out1 \n”);
fprintf(stdout,”hello-out2 “);
fprintf(stderr,”hello-err “);
return 0;
}
Output:
hello-out1
hello-err hello-out2