I made a function that receives a file pointer. That file pointer was set in write mode from main. How can i change it inside the function to read mode now? If i use fopen or freopen i have to give filename but don't we already have that information once the function receives the FILE pointer as argument? I don't want to create a new parameter just for this.
Code:
void ListStuff(FILE *f)
{
//How do i turn f into read mode here?
}
int main()
{
char fileName[50];
printf("file name? ");
scanf("%s", fileName);
char auxFile[50];
sprintf(auxFile, "%s.txt", fileName);
FILE *f;
f=fopen(auxFile, "w");
if(f==NULL)
{
printf("Error\n");
return 0;
}
ListStuff(f);