I'm trying to open different files by having a for loop increment a counter, then appending that counter to the filename to be opened, but I'm stuck on how to use strcat to do this. If I understand right, strcat takes 2 strings, but my counter is an int. How can I make it so that it becomes a string?
for(a = 1; a < 58; a++) {
FILE* inFile;
int i;
char filename[81];
strcpy(filename, "./speeches/speech");
strcat(filename, a);
strcat(filename, ".txt");
Definitely doesn't work since a is an int. When I try casting it to char, because a starts at 1 and goes to 57, I get all the wrong values since a char at 1 is not actually the number 1.. I'm stuck.