Click here to Skip to main content
15,915,703 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi i have a problem when i try to write a .txt file i get this:
> error expected initializer before FILE and error expected constructor, deconstructor, or type the conversion before ( token

i tried to put it out of the function but there is the same error


int printname()
FILE *f
f = fopen ("name.txt", "r");
fprintf(f, "Song :%s\n", filename);`

what can i do?
Posted
Comments
[no name] 7-Sep-15 20:39pm    
Use some initiative. Google "How Do I Print Text To A File? C++". It will even correct the syntax for you. There, I've answered your question.

1 solution

Your solution: Learn the language !
Sure I could have give you a working code but it almost involve rewriting all this code. It would make it a magic solution.
I see that you barely know the syntax of the language. There is more errors that lines is this piece of code.

So I have an advice that will be more productive for you:
- read documentation, manuals, books ...
- Google is your friend.
- follow tutorials, you can find tutorials about any aspect of the language.
- Abuse of debugger to see your code running and every time you get a runtime error.

There is not short cut to knowledge, don't skip steps.
Programming is the art of details, and it takes time to master this art.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900