I'm new to C and I have a question I think it's not that complicated. I'm trying to write a code that creates strings like : File1,File2,File3, etc.
Here is my code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
int main(void){
char string1[80]="File";
char string2[80]="";
int number = 10;
int i;
for (i=0;i<number;i++){
sprintf (string2,"%d",i);
strcat( string1, string2);
printf("Characters: %s \n" , string1);
char string1[80]="File";
char string2[80]="";
}
return 0;
}
But what I'm getting is File0,File01,File012,...
Could you please tell me how to solve this?