Jump to content

[C] Dúvida: Invalid lvalue in assignment


Recommended Posts

Posted

Olá pessoal...

Esta linha de codigo que vou escrever faz parte de um "longo" programa que tenho andado a escrever(3 dias) e realmente só me resta esta linha(e outra igual noutra função) que me dá um erro que não entendo.

if(fich_dados = fopen(file_salds,"w+")== NULL || fich_dados2 = fopen(file_movs,"a+")== NULL)

Pronto... o erro que me dá é o seguinte: invalid lvalue in assignment

Any help?

Posted

tenta

if (((fich_dados = fopen(file_salds,"w+")) == NULL) || ((fich_dados2 = fopen(file_movs,"a+"))== NULL))

Se não estou enganado o == tem prioridade sobre o =, logo estavas a atribuir aos ficheiros não um fopen, mas sim um booleano true/false. Isto é claramente um valor inválido para se atribuir a um ficheiro.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.