Nov 8, 2017 at 1:53am UTC
i have a text file which has a destination of some files. it is as below.
"E:\Feature\raw\new\frameSplit62.png"
i have many photos and i want a c++ code to change the image everytime i run the code.(loop).i only need to change the image number (62). from like 1- 100 for example.
please help
Last edited on Nov 8, 2017 at 1:54am UTC
Nov 8, 2017 at 6:43am UTC
thank you for this.this was a great help. can you tell me if i want to get the images in an order without taking random images what should i change
Nov 8, 2017 at 8:00am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <string>
std::string next_file_name()
{
static std::string prefix = "E:\\Feature\\raw\\new\\frameSplit" ;
static std::string suffix = ".png" ;
static const int ub = 100 ;
static int n = 0 ;
return prefix + std::to_string( n++ % ub + 1 ) + suffix ; // for 1 to hunfred
}
int main()
{
for ( int i = 0 ; i < 10 ; ++i )
std::cout << "file name: " << next_file_name() << '\n' ;
}
http://coliru.stacked-crooked.com/a/6c9de02a17abe87f
Last edited on Nov 9, 2017 at 3:23am UTC
Nov 8, 2017 at 5:55pm UTC
this doesnt make a text file(.txt) and print the generated links right??
Last edited on Nov 8, 2017 at 5:57pm UTC
Nov 9, 2017 at 3:29am UTC
> this doesnt make a text file(.txt) and print the generated links right??
No it does not; it prints the generated file names to stdout .
To write them to a file, use an output file stream std::ofstream instead of std::cout .
There is an edit in the code posted earlier; it now generates file names with image numbers 1 to 100.
Nov 9, 2017 at 6:08am UTC
you have done a great help. thank you very much
Nov 12, 2017 at 1:17pm UTC
@JLBorges can you help me to edit your code to give an txt file output.