Objective-C lyrics parsing, objective-c Parsing
# Import <Foundation/Foundation. h> int main (int argc, const char * argv []) {FILE * fp1; // defines the FILE pointer for reading the FILE char * fp2; // used to judge whether the lyrics have been read char s [80]; // temporarily saved lyrics long int time2 = 0; long int time = 0; // used to calculate the time, accurate to seconds, not perfect, hope the high person points int a = 1; // plays a judgment role fp1 = fopen ("/Users/qingyun/Desktop/Dream. lrc "," r "); // opened in Direct Read mode. The path can be macro-defined fgets (s, 1000, fp1); // For the output name while () {a ++; if (s [a] = ']') {break;} s [a] = '\ 0'; printf ("song name: % s \ n ", & s [3]); sleep (3 ); Fgets (s, 1000, fp1); // to output singer name a = 1; while (a) {a ++; if (s [a] = ']') {break ;}} s [a] = '\ 0'; printf ("singer: % s \ n", & s [3]); sleep (3 ); fgets (s, 1000, fp1); // because some lyrics have other attributes, only the song name and singer name are output for compatibility, followed by the lyrics while (s [1]! = '0') {fgets (s, 1000, fp1);} while (fp2! = NULL) // judge whether the lyrics have been read {time = (s [1]-'0') * 60000 + (s [2]-'0 ') * 6000 + (s [4]-'0') * 1000 + (s [5]-'0') * 100 + (s [7]-'0 ') * 10 + (s [8]-'0') * 1; printf ("% s", & s [10]); while (time> time2) {sleep (1); time2 + = 100;} fp2 = fgets (s, 1000, fp1) ;}fclose (fp1); // close the file return 0 ;}