Main () call main ()

xiaoxiao2021-03-05  27

About the main function call the main function, and jump out of the program! I have done some research! Let's send it to you! There are three ways: 1: Using external variable #include int i = 0; main () {i ; if (i> 10) {exit (0);} printf ("% d / n", i Bioskey (1); main ();} "MS-Girl provides" Method 2: Use static variables: #include "stdio.h" main () {static int = 0; i ; if (i> 10) {EXIT (0);} printf ("% d / n", i); bioskey (1); main ();} I think about the method I think 3: Use the file: establish a file 1.H Write EXTERN INT i = 1; save. #include "stdio.h" #include "1.h" main () {i ; if (i> 10) {exit (0);} Printf ("% d / n", i); bioskey (1); Main ();} But Leibo provides the method: #include #include int i = 1; void main () {

File * fp; if ((fp = fopen ("INPUT", "W")) == null) {PrintF ("canNot Open file / n"); exit (1);} fscanf (fp, "% D / N ", & I); Printf ("% d / n ", i); i ; if (i <10) {fprintf (fp,"% d ", i); fclose (fp); main ();}} / * The * / is only the extension of the first method! Change to #include #include int i = 1; void main () {

File * fp; if ((fp = fopen ("INPUT", "W")) == null) {PrintF ("canNot Open file / n"); exit (1);} fscanf (fp, "% D / N ", & I); Printf ("% d / n ", i); i ; if (i <10) {fprintf (fp,"% d ", i); fclose (fp); main ();}} Can't do it! Dead cycle! Perhaps there is another way to study yourself! But #include main () {INT i = 0; i ; if (i> 10) {exit (0);} Printf ("% d / n", i); bioskey (1); main ();} Is absolutely not! This question just judges the MAIN () call out of the main () function! I have time to study!

转载请注明原文地址:https://www.9cbs.com/read-34224.html

New Post(0)