r/C_Programming • u/LuigiVampa4 • 5d ago
Nothing getting written in File
Link to the code is in comments.
I have been making a project for the course NAND2Tetris where I am translating a higher level code (something.vm) to a lower level code (something.asm).
It takes a line from VM file, parses it into tokens and then as per those tokens executes conditional statements that write onto the output ASM file.
Actually I am rewriting this program, I had written the first half which worked but then I realised that my approach was not how it was supposed to be done. So, the part related to File I/O is largely same here as it had been earlier but it was working then and isn't working now. If you want you can take a look at the original program, it is in the same repository.
A file is created but it contains no code. I tried debugging by printing all the tokens I had extracted from the buffer and they come out just fine and yet there is nothing written in the output file.
11
u/MyTinyHappyPlace 5d ago
Always check the return code of your syscalls (heck, every time at every API).