How to make a increasing numbers after filenames in C?
Posted
by zaplec
on Stack Overflow
See other posts from Stack Overflow
or by zaplec
Published on 2010-06-10T06:35:01Z
Indexed on
2010/06/10
6:42 UTC
Read the original article
Hit count: 266
Hi,
I have a little problem. I need to do some little operations on quite many files in one little program. So far I have decided to operate them in a single loop where I just change the number after the name. The files are all named TFxx.txt where xx is increasing number from 1 to 80. So how can I open them all in a single loop one after one? I have tried this:
for(i=0; i<=80; i++) {
char name[8] = "TF"+i+".txt";
FILE = open(name, r);
/* Do something */
}
As you can see the second line would be working in python but not in C. I have tried to do similiar running numbering with C to this program, but I haven't found out yet how to do that. The format doesn't need to be as it is on the second line, but I'd like to have some advice of how can I solve this problem. All I need to do is just be able to open many files and do same operations to them.
© Stack Overflow or respective owner