Thread: Filenames in a directory

  1. #1

    Filenames in a directory

    Hey,
    I need to add smilies to a board, and I have over 600. I need to know how can I tell C++ to get a filename for a directory, and add that and some stuff to a txt file. It goes like this :

    smoke.gif=+:Smoking=+::smoking:
    icon_biggrin.gif=+:Very Happy=+:;D
    icon_biggrin.gif=+:Very Happy=+::grin:


    So I need to be able to grab a name eg. smiley1.gif, add =+:A smiling smiley=+::smile:, and then go to next line.

    How can I make a program grab a filename ?

    Thanks
    Dev C++
    Win XP/2k/98

    I DO NOT TAKE CLASSES I DONT GET HOMEWORK THIS IS NOT A HOMEWORK QUESTION!!!

    He's lean he's keen... He's the spank machine!

  2. #2
    Code:
    #include <fstream.h>
    #include <iostream.h>
    #include <string.h>
    
    char name[30];
    char mod[30];
    
    int main()
    {
    name = "weird.txt";
    
    for(int x = 0; x < 50; x++)
    {
    if(name[x]=='.')
    {
    for(int y = 0; y < x; y++)
    {
    mod[y] = name[y];
    }
    }
    }
    
    cout << mod;
    cout << endl << name;
    
    cout << endl << endl;
    
    return 0;
    }

    That's what we're after...
    Dev C++
    Win XP/2k/98

    I DO NOT TAKE CLASSES I DONT GET HOMEWORK THIS IS NOT A HOMEWORK QUESTION!!!

    He's lean he's keen... He's the spank machine!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 02:54 AM
  3. Replies: 6
    Last Post: 07-30-2003, 03:08 AM
  4. Replies: 2
    Last Post: 04-14-2002, 01:03 PM
  5. Directory reading trouble
    By samGwilliam in forum Linux Programming
    Replies: 0
    Last Post: 03-10-2002, 09:43 AM