Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,150,831 members, 7,810,200 topics. Date: Friday, 26 April 2024 at 11:16 PM |
Nairaland Forum / Science/Technology / Programming / Learn File Struction With C Language (842 Views)
Need Help With A C Language Problem Can You Be Of Help / Coding Virus To Kill Computer In C++ Language / GP Calculator With C Language (2) (3) (4)
(1) (Reply)
Learn File Struction With C Language by silento(m): 5:22pm On Sep 13, 2016 |
lets start with basic mp3 id3 tags visit http://id3.org/ID3v1: to learn more mp3 id3 tags looks some thing like this: typedef struct mp3_id3 { char Tag[3]; char Song_Title[30]; char Artist[30] ; char Album[30]; char Year[4]; char Comment[30]; char Genre[1]; }MP3Id3; or typedef struct mp3_id3 { BYTE Tag[3]; BTYE Song_Title[30]; BTYE Artist[30] ; BTYE Album[30]; BTYE Year[4]; BTYE Comment[30]; BTYE Genre[1]; }MP3Id3; last 128bytes of an mp3 file contains the tags of an mp3 files with an above info lets create a program to read the info from an mp3 so i wrote this little program with c language : #include <stdio.h> #include <stdlib.h> #include <string.h> int in(char *item,char *mp); int Len(char *items); char *readit(char* src,int size); typedef struct mp3_id3 { char Tag[3]; char Song_Title[30]; char Artist[30] ; char Album[30]; char Year[4]; char Comment[30]; char Genre[1]; }MP3Id3; int main(int*argc,char **argv[]) { //decl MP3Id3 MP3Id3 tag; //Open mp3 file for test FILE *file = fopen("3.mp3","r" //check and seek to the last 128byte to read tags for our mp3 file if((fseek(file,-128,SEEK_END)||fread(&tag,1,sizeof(tag),file)) !=1) { printf("ERROR WHILE PROCESSING MP3" return 0; } fclose(file); //check to find TAG to see if we had a vaild tag data char *temp = (char*)malloc(3); int i; for(i=0;i<3;i++) { *(temp+i)=tag.Tag[i]; } *(temp+3) = '\0'; if(in("TAG",temp)!=1) { printf("DUMPED DATA NOT VALID MP3 TAG or NO Tag on MP3 File \n" } free(temp); printf("Artist Name : %s \n\n",readit(tag.Artist,sizeof(tag.Artist))); printf("Album name : %s \n\n",readit(tag.Album,sizeof(tag.Album))); printf("Album Year : %s \n\n",readit(tag.Year,sizeof(tag.Year))); printf("Song Title : %s \n\n",readit(tag.Song_Title,sizeof(tag.Song_Title))); printf("Track Comment : %s \n\n",readit(tag.Comment,sizeof(tag.Comment))); return 0; } int in(char *item,char *mp) { int r,l,j=0,chk=0; l = Len(mp); for(r=0;r<Len(item);r++) { if(mp[j]==item[r]) { chk+=1; j+=1; } else { chk=0; j=0; } if(chk==Len(mp)) { break; } } if(chk==Len(mp)) { return 1; } else { return 0; } }//end of func in int Len(char *items) { int i=0; int ii=0; while(i !=1) { char a = items[ii]; ii++; if(a=='\0') { i=1; }; } return(ii-1); }//len of a string char *readit(char* src,int size) { char *dst; //printf("%d ",size); dst = (char*)malloc(size+1); int i=0,s=0; for(i=0;i<size;i++) { //printf("%d \n",*(src+i)); if(*(src+i)==32) { //break; } else { *(dst+s)=*(src+i); s++; } } *(dst+s)='\0'; return dst; } if u need help holla i will be here to guide u ; 1 Like |
Re: Learn File Struction With C Language by codeSavant: 9:39pm On Sep 13, 2016 |
tanx... |
Re: Learn File Struction With C Language by silento(m): 9:57pm On Sep 13, 2016 |
codeSavant: you are welcome am writing update for my video converter this is some part of the code more c examples loading next how to setup a complete and easy GUI library in c langaue 1 Like |
(1) (Reply)
Android Developer Needed / Woocommerce Plug-in Developer, Presta Shops,opencart Extensions Developers. / No Language Barrier On Skype
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 21 |