Originally Posted by
yann
But, how can I make a file that has the name I inputed?
Code:
#include <stdio.h>
#include <string.h>
#define SUF ".txt"
int main(void) {
char name[32];
printf("Enter a name: ");
scanf("%27[a-zA-Z0-9_-]", name);
strcat(name,SUF);
fopen(name,"w");
return 0;
}
If you want to attach a name to a struct, include it as a member:
Code:
struct mystruct {
char name[32];
};
struct mystruct example;
So the name can go in example.name ...if example were an array:
Code:
struct mystruct example[10];
example[0].name can be different than example[1].name, etc.