The meaning of this program is not to pay attention, given only as an example. Only interested in writing to the file through the function

http://ideone.com/KBnfBW

If something is wrong, please indicate shortcomings.

  • four
    The question is not very clear. Are you interested in whether it is possible to call a function with a FILE * parameter so that it writes something to the transferred file? Yes you can. Shortcomings. At least: 1. It is necessary to check whether the file is successfully opened. 2. At normal completion, end the program return 0; (or exit(0); ). - avp
  • > Are you interested, is it possible to call a function with a FILE * parameter so that it writes something to the transferred file? Exactly. > It is necessary to check whether the file is successfully opened. Can be more? Check in f-and head (in this example)? Or in the main? > With normal completion, end the program return 0; (or exit (0);). Yes, I know about it, but so far (for some reason) have been told to write without it. - froxxendsg
  • one
    Check in main. For your code, write, for example: ... if (! (F = fopen ("000.txt", "w")) {perror ("output file"); exit (1);} ... Instead of .. . f = fopen ("000.txt", "w"); ... Only the idea of ​​using such a function (without parameters) is not too good. You will have to make all recorded data global, and it’s better not to get used to it. - And If there is such an opportunity, then immediately start programming in * nix (for example, in Linux). You will still have time to suffer with Windows. - avp
  • > Check in main. For your code write, for example, Thank you. > Only the idea of ​​using such a function (without parameters) is not too good. You will have to make all recorded data global, and it’s better not to get used to it. Is it possible here, too, in more detail? Meaning the main function? > And more. If there is such an opportunity, then immediately start programming in * nix (for example, in Linux). To suffer with Windows still have time. That's the problem that there is no possibility, more precisely, in the university you need a win (and if more precisely, a dos). For your experience, writing under * nix is ​​no problem. - froxxendsg 7:55
  • one
    > I meant the data that head () will write to the file. The data will be transmitted through the parameters of the head() function, just in this example I decided to omit them (in order to leave only the essence of the question). Yes, thanks, now your thought has become clear to me. ------------------- (I did not think that there is a restriction on the number of comments ..) - froxxendsg

0