Hello friends ,
I was just surfing the net late in night and then I came to see some interesting C codes . So here we go-
1) Suppose if one want to know the program name through the execution of code itself , then code for this is –
#include<stdio.h>
int main()
{
printf(“the source file name is %s\n”,__FILE__);
return 0;
}
What happens here in this program , __FILE__ is actually a macro which stands for the file name in which program is kept in.
Just use this keyword in the program and compiler will do the rest .
2) Suppose if we have a situation in a program where we are taking an input which is not going to be used then we have to use a variable to store that input like scanf(“%d”,&a) , means wastage of memory . But we have a technique to avoid this –
What we do for this , just use the scanf statement like this –
scanf(“%*d”);
by using * here we force scanf to scan input from the standard input but it won’t assign to any variable .(This is scanned in a buffer of sufficient size and you don’t need to worry about that !
This section will be continued , wait for the next post !
Till then happy coding , 🙂
#include<stdio.h>