Hello everyone,
Firstly, I just wanted to say thank you again to all of you who have been helping me with the resurrection of my C programming. Your help has been invaluable and I have made great progress as a result.
Along the way, I have realised that I don't need OOP for my project, so I have suck with C as I have used it in the past and it's less 'new' to learn for my goals.
The one problem I have left is that I can't for the life of me work out how to save a file to the same folder as the command line app is run from. This is the code I am using so I can save a different file for each of the runs my app makes:
At the moment, it saves to the same folder as the built program buried deep if the bowels of Xcode if I run it from Xcode, otherwise it just dumps into my user folder. I have tried to put a slash (either way) before the string but to no avail.
Any ideas?
David
Firstly, I just wanted to say thank you again to all of you who have been helping me with the resurrection of my C programming. Your help has been invaluable and I have made great progress as a result.
Along the way, I have realised that I don't need OOP for my project, so I have suck with C as I have used it in the past and it's less 'new' to learn for my goals.
The one problem I have left is that I can't for the life of me work out how to save a file to the same folder as the command line app is run from. This is the code I am using so I can save a different file for each of the runs my app makes:
Code:
void SaveToBinaryFile(void)
{
FILE *Binfp = NULL;
char binbuffer[32]; // The filename buffer.
snprintf(binbuffer, sizeof(char) * 32, "FileD%iGen%i.dat", Max , CurrentG );
Binfp = fopen(binbuffer, "a");
.....
At the moment, it saves to the same folder as the built program buried deep if the bowels of Xcode if I run it from Xcode, otherwise it just dumps into my user folder. I have tried to put a slash (either way) before the string but to no avail.
Any ideas?
David