Some Bugs in Programing
[codesyntax lang=“c” tab_width=“2”]
1 | #include<stdio.h> |
it will never stop, because the condition of i != 5 will never satisfied. If you want to count, using int type. When you compare two double type number, you should use fabs(a-b) < 0.001, 0.001 is threshold. Sometimes, double is not precision. macro is a great tool, but it is also dangerous. I often forget the language of define. The correct language is :
#define
#if defined
#if !defined
#ifndef
#ifdef
#endif
compile .c file with math lib in linux. It will be like that: cc test.c -o test -lm
stdio redirect to file use freopen() function. like that:
1 | #include<stdio.h> |
if you want redirect to file, use the code and compile it with -D REDIRECT. cc test.c -o test -D REDIRECT
If you want to use struct FILE to do the same thing:
[codesyntax lang=“c” tab_width=“2”]
1 | #include<stdio.h> |
try cc t3.c -o t3 -lm -D REDIRECT and cc t3.c -o t3 -lm