how to format a .txt file in working directory so it can be opened and read on Mac in CLion C executable
Answered
I have put the .txt file in the same directory and reconfigured the working directory to the and it still doesn't work the code works and can open .txt files using other IDE's
Please sign in to leave a comment.
Hello! CLion looks for input files and writes output files to the "generation path" folder (
cmake-build-debugby default, can be set inFile | Settings | Build, Execution, Deployment | CMake | Generation path). If you put your input file in this folder, CLion will be able to open it. Or you can just try setting an explicit path likeC:/<path_to_file>/data.txtininput_file.open().@Anna Falevskaya its very strange CLion can see the file and opens the file but then the program crashes straight away leaving an error code 6 can any one send screen shots of a simple code in c and the file formatting that opens a file because I think iv tried everything.
See, for example, this article - https://www.programiz.com/c-programming/c-file-input-output.
Learn python basics Python Tutorial http://”https://www.theversetech.com/2020/02/python.html/”
I am using Linux, not Mac. When I use FILE *fp=fopen("filename.txt",w); it works but I do not know where it is (as the following field (Generation path) does not exist: File | Settings | Build, Execution, Deployment | CMake | Generation path). When I use FILE *fp=fopen("/home-directory/filename.txt",w); (home-directory is any directory which I created after my home), the open file fails (return null).
>as the following field (Generation path) does not exist: File | Settings | Build, Execution, Deployment | CMake | Generation path
It's now called "Build directory".
After using Build Directory to select a directory which I created, /project-directory/debug (thanks for the tip), and executing FILE *fp=fopen("filename.txt",w); ...; fprintf(fp, "%f ", src_rotation[i]); fclose(fp); the directory .../debug is still empty. Again why FILE *fp=fopen("/project-directory/filename.txt",w); should fail?
Hi William!
Sorry for the delay. Did you run your project? The file should be created next to the executable, in the Build Directory.