How to insert a string in side other string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mpage
    New Member
    • Nov 2007
    • 3

    How to insert a string in side other string

    Hi, this is my first post and i dont have a very good english so I'll try to do my best....

    I'm working with image processing in C++, for that I read the file name from console , I open the file I work with it and then I want to create a file with the same name of the image with a "_res" added....

    so for example if the image name is "image1.bmp " what i want to save is "image1_res.bmp ".... but when I'm working with te string for same reason i can only get staff like this... "image1@*$_res. bmp".

    For opening the image and saving it im using a open source libery. : FreeImage.

    This is what im doing....:

    Code:
         char *input_dir = new char[260];;
         char image_path[260];            
         getFilePath(input_dir, image_path);   
       
         // batch convert all supported bitmaps
         _finddata_t finddata;
         long handle = _findfirst(image_path, &finddata);
         //
          ....
         //
  • mpage
    New Member
    • Nov 2007
    • 3

    #2
    and when i want to create the new file name i do this



    Code:
           int largoNom = strlen(finddata.name);
           largoNom += 5;
           char *unique = new char[largoNom];
           largoNom -= 9;
           strncpy(unique,finddata.name,largoNom);
           strcat(unique,"_res");
           strcat(unique,".bmp");
           FunFI::GenericWriter(dib, unique, PNG_DEFAULT);

    If I show in console unique and finddata.name its the same thing i was telling you, so it isnt a problem with te libery.

    Comment

    Working...