if u want to create a file using a variable by taking its value from input data file,then your code should be in this pattern.

char ch[10];/*say input.dat contains data as 'output'*/
FILE*fp,*ft;
fp=fopen("input.dat","r");/*fp is input file pointer*/
if(fp==NULL)
{
puts("error")
}
while(fscanf(fp,"%s",&ch)!=EOF);
     printf("%s",ch);
sscanf or sprintf(ch,"%s.txt",ch);
ft=fopen(ch,"w");
if(ft==NULL)
{
puts("error");
}
fclose(fp);
fclose(ft);

I wouldn't put it in that pattern. I'd format the code so it can be read by others.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.