VS Code creating text file in wrong directory (possible path issue) - c++

I'm creating a program in C++ on VS Code macOS. I have this line of code:
fileO.open("writing.txt", ios::app);
which is supposed to open a new .txt file and save whatever the user inputs into my program. However, VS Code is opening the file under the directory /Users/username instead of the directory where my program is located, which is /Users/username/Downloads/firstprogram/code.cpp. This seems to be a very simple problem but I cannot seem to find a correct answer for this. I only get results for non-relevent threads about directories in VS Code.
It is still able to access the same writing.txt file when I re-run my program and the .txt file still keeps the previous data. My program works 100% correctly because I coded it in a school-based linux ssh shell/editor and it was perfectly fine. This is a VS Code issue.
I have been unable to fix it despite following the VS Code macOS setup for C++. My launch.json files and tasks.json files have also been updated to match the files on the official VS Code website but I am still encountering issues related to the path of files being created. This is very confusing because I've never had this happen to python files that I create using programs, but it's occurring for my C++ programs. Any suggestions on what to do?

Related

Unable To Locate or Access 'System.Data.Common' CLR C++ Winforms Project

I'm having an issue where I can run and use a compiled version of my project on my computer, but the moment i put the release onto another computer to run it pops up with a console for a split second saying it can't open System.Data.Common. I'm using .Net Version 4.7.2 and this is installed exactly the same on my other computer. I've even tried install VS on that one to compile the program from source code and it still doesn't work. I've checked the file it is getting the System.Data.Common.dll from and it is there and installed in the correct folder. I've tried removing it from the project through the project file and config file and I still get the same thing. It just seems to be the one dependency it is messing up for. I don't have a direct screen shot of the error since it is on another computer I was testing for but it just says that error and then says line 9 of login.cpp and that is just opening the form. Although System.Data is a necessary package for my project (since I need Data Tables), I do not use anything from System.Data.Common so if there is a way i can get it to not be considered on compilation other than the methods I've already tried, that will work too.
I have tried to remove the dependency from the vcxproj file and vcxproj.filters file. This did not work. I tried reinstalling .Net 4.7.2 on the computer I wanted to install it on. I've also tried removing the dependency from the exe.config file and none of these have worked. My last resort it to just straight up copy and paste all the code into a fresh project and keep going until I get the same error.

Code::Blocks: Fortran EXECUTE_COMMAND_LINE The specified path does not exist

I am trying to use EXECUTE_COMMAND_LINE (Fortran) in Code::Blocks to start a program through a shortcut with the Windows command prompt. I have checked the path and the syntax several times, and everything is correct, however whenever I compile and run the code, when the script reaches this command I get an error saying that "The specified path does not exist. Check the path and then try again.".
Even more peculiar is the fact that, using the exact same command within the EXECUTE_COMMAND_LINE directly in the command prompt successfully launches the application with no problems whatsoever.
The command I use is the following:
CALL EXECUTE_COMMAND_LINE("start C:\Users\dimpa\Desktop\Giannako\Optimization\VBA\SLDA.lnk")
I run Windows 10, Code::Blocks 20.03 and have the MinGW compiler for Fortran.
Have also used SYSTEM with exactly the same results. Also, if it is to any use helping me figure out what is going on, this command works just fine:
CALL EXECUTE_COMMAND_LINE("start C:\Users\dimpa\Desktop\Giannako\Optimization\VBA")
Opening the folder VBA to my File Explorer. The problem seems to be related with opening the shortcut of the application. Further more, opening files located in dimpa\Appdata folder (original .exe, not the shortcut) seems to be working even through the IDE, where anything in Program files is inaccessible.
Thanks in advance.
Cheers, after endless experimentation, I seem to have found a workaround.
The problem was revolving around spaces being included in the path of the original program of the shortcut in use. Apparently the compiler isn't fond of executing shortcuts, which might initially not contain spaces in the initial path, but when redirected to the original program can run into all sorts of things.
The shortcut that I was trying to execute contained a path leading into Program Files and opened an additional addon to be executed in the aforementioned program ("/m"). After realizing that trying to run a shortcut with a 150 string length target could complicate things, I directly entered the target of the shortcut into the Windows cmd, which worked perfectly fine and was much more easier to dissect and be examined in order to properly write the code:
CALL SYSTEM(""Full Path to Program" "/m" "Full Path to Addon"")
Hope this helps someone facing similar issues!

Nothing happens when trying to execute .exe files c++ project g2o

I generated the .exe files by running 'make' for the c++ project g2o. However when I try executing them, a black window appears for a short time, but nothing else happens. Does it mean something went wrong when creating them? I generated them again using the source code from https://github.com/RainerKuemmerle/g2o, which resulted in the same problem.

Processing.exe Doesn't Respond to System() (c++)

I exported my Processing project, which renders as P3D, successfully. The .exe file works, even from the command line. I need to run this executable from a c++ program. When I call
system("Project_name.exe");
on it, it doesn't open up the file. I checked the path by opening other types of files like .txt successfully. I also tried it with system("start Project_name.exe")and it gives the same input.
Is it because its not reading java with the app properly? The java folder is also in the same directory. I am using VS 13 Pro. Please help!
Note: I understand system calls are not the best approach. I also used CreateProcess but was not successful. I think the file is opened but the frame and contents doesn't display.
Thank you
System command works fine in case of interactive applications, starting notepad works fine.
Please ensure your application and dependencies are picked up from the right path, You may try to set path environment variable within c++ application.
If you are able to run this application from command line, you may write a batch file to invoke your application and invoke this batch file from c++ application using system command

Unable to save the file with .cpp format insted of .cpp.9.0 format in VCExpress

I decided to try Visual C++ Express and didn't like it so I went back to Code::Blocks. However, when I tried to run a program in Code::Blocks I noticed that all of my files were saved under the format VCExpress.cpp.9.0. I deleted all of the files and went to where I have all of them uploaded to re-download them. However, they keep being saved as VCExpress.cpp.9.0. Can anyone offer assistance? Thanks.
P.S. They were uploaded before I ever tried VCExpress
If I try to compile one of these files I get an error saying "There is no disk in the drive. Please insert a disk into drive D:." In short, all cpp files are being saved as VCEXpress.cpp.9.0. I need to stop that file extension change from happening.
See if re-installing Code::Blocks fixes the problem.