Thread: I/O File Don`t know what´s happening

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    3

    I/O File Don`t know what´s happening

    I`m doing this program that edits the mp3 tags, the thing is that it write the drirectory name as the Artist and the filename as the Song Title. So the program is working fine but at the moment to write it doesn´t work. Here is the code:

    Code:
    void __fastcall TForm1::DirectoryListBox1Change(TObject *Sender)
    {
    FileListBox1->Directory = DirectoryListBox1->Directory;
    char buff[124];
    char artist[30];
    char name[30];
    int i;
    TSearchRec sr;
    if (FindFirst(DirectoryListBox1->Directory + "\\\\*.mp3", faArchive, sr) == 0)
    {
    do
    {
    if ((sr.Attr & faArchive) == sr.Attr)
    {
    fstream stream(sr.Name.c_str(),ios::in | ios::out);
    stream.seekg(sr.Size-125);
    stream.getline(buff,124);
    for(i=0;i<30;i++)
    {
    artist[i]='\0';
    name[i]='\0';
    }
    strcpy(artist,Form1->DirectoryListBox1->Directory.c_str());
    strcpy(name,sr.Name.c_str());
    stream.seekg(sr.Size-125);
    stream.write(artist,30);
    stream.write(name,30);
    stream.close();
    }
    } while (FindNext(sr) == 0);
    FindClose(sr);
    }
    }
    //---------------------------------------------------------------------------
    Looking forward your awnser


    Code tags added by Hammer
    Disable Smilies in This Post by Salem

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    according to the following lines :

    strcpy(artist,Form1->DirectoryListBox1->Directory.c_str());
    strcpy(name,sr.Name.c_str());

    it sounds like the code is working as written. Presumalby, Directory.c_str() returns the null terminated string representing the name of the Directory to which the pointer string points to.

    Since sr.Name.c_str() is used as the filename to which stream is associated then it should be whats in name as well.

    I suspect what you want to do is to take apart the stuff read into buff and put some of it in artist and some of it in name, and then write out the values of artist and name; otherwise why bother to read something into buff in the first place.

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    3
    The probles is just the lines:

    stream.write(artist,30);
    stream.write(name,30);

    do not work, but I`m sure that artist and name are fill with the strings.

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    3
    here is the code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. File I/O Assertion Failure in VS2008
    By clegs in forum C Programming
    Replies: 5
    Last Post: 12-25-2008, 04:47 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. 2 questions surrounding an I/O file
    By Guti14 in forum C Programming
    Replies: 2
    Last Post: 08-30-2004, 11:21 PM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM