Wednesday 15 January 2014

c - How would i make this program loop the main twice? -


I need my program to create two separate text files (Midinotes 1 and Midnight 2) and both of them Need to store two bits of middle data later read what is an effective way without copying the code? I understand that I want to write midinotes1 and filepointer2 to write filepointer1 to write midinotes2, but I do not know how to do my program? Thank you for any advice!

  Include # "aservelibs / aservelib.h" #include & lt; Stdio.h & gt; # Include & lt; Math.h> #include & lt; String.h & gt; Float MTOf (int note, float frequency); Int main () {FILE * textFilePointer; FILE * textFilePointer2; Int note; Int velocity; Int program; Int counter = 0; Four users; Float frequency; Do {printf ("press r (recording r) or (x) to exit: \ n"); Scanf ("% c", and Users); If (user == 'r' || user == 'r') {textFilePointer = fopen ("/ user / Luke / desktop / midnight 1.txt", "w"); Counter = 0; If (textFilePointer == NULL) {printf ("Error opening file. \"); } And {do {note = aserveGetNote (); Velocity = aserveGetVelocity (); If (velocity> 0) {fprintf (text filepoint, "% d \ n,% d \ n", note, velocity); Counter ++; } Program = aserveGetProgram (); } While (counter <16); Fclose (textFilePointer); }} And if (user == 'X' || user == 'X') break; } While (user! = 'X' || user! = 'X'); Return 0; } Float MTOF (int note, float frequency) {frequency = 440.0 * POW (2, (note-69) / 12.0); Printf ("% d \ n", note); Return frequency; }  

  index index = 0; Four filenames [128]; Do {printf ("press r (recording r) or (x) to exit: \ n"); Scanf ("% c", and Users); If (user == 'r' || user == 'r') {snprintf (filename, 120, "notes% d.txt", (index + 1)); TextFilePointer = fopen (filename, "w"); Counter = 0; If (textFilePointer == NULL) {printf ("Error opening file. \"); } And {{{doing your work} (counter <16); Fclose (textFilePointer); Index ++; }} And if (user == 'X' || user == 'X') break; } While (user! = 'X' || user! = 'X'); Return 0;  

No comments:

Post a Comment