Timeline for C++ can't create txt files
Current License: CC BY-SA 4.0
19 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 12, 2025 at 19:33 | comment | added | Thomas Matthews |
FYI, std::cin may not be compatible or use stdin. Don't cross the streams. If you want to use stdin, then use the fscanf, fread, fgets functions. If you want to use std::cin, the use std::fstream varieties.
|
|
| Jan 12, 2025 at 17:23 | comment | added | 3CEZVQ | No antivirus programs on PC, no Windows Defender, no windows 11 UAC. Your PC looks like to be full of viruses. | |
| Jan 12, 2025 at 16:56 | comment | added | Ted Lyngmo | @HMSTree Perhaps it'll be clearer if you change your program to this so that you see the full paths: godbolt.org/z/zYfxzEK7z | |
| Jan 12, 2025 at 16:30 | comment | added | drescherjm | Maybe you should take VSCode out of the equation and compile your program directly in a msys2 terminal. That way you can begin to narrow down why you have this problem. | |
| Jan 12, 2025 at 16:22 | comment | added | drescherjm |
Maybe you have multiple instances of the MinGW runtime dlls installed and have an incompatible version in one of the folders of your PATH environment variable causing https://en.wikipedia.org/wiki/DLL_hell because of the incompatible runtime.
|
|
| Jan 12, 2025 at 16:13 | comment | added | HMS Tree | I already did this, no error | |
| Jan 12, 2025 at 16:12 | comment | added | Ted Lyngmo |
Use std::ifstream/std::ofstream and print the error if opening fails and then you'll know why it doesn't work.
|
|
| Jan 12, 2025 at 15:47 | history | edited | HMS Tree | CC BY-SA 4.0 |
added 161 characters in body
|
| Jan 12, 2025 at 15:43 | comment | added | HMS Tree | I also try tested this with my friend with Windows 11, we installed to him vs code, mingw and code runner, freopen and ofstream works just file on his pc. So this code is working code, but it do not work on mine, what can cause this? | |
| Jan 12, 2025 at 15:31 | comment | added | Pepijn Kramer | ofstream should work, but be sure you set the "working directory" of your final directory to a place where you have rights to write files. Considering the link you sent : make sure you practice on Linux (so you are familiar with the linux file system behavior too). | |
| Jan 12, 2025 at 15:27 | history | edited | HMS Tree | CC BY-SA 4.0 |
added 353 characters in body
|
| Jan 12, 2025 at 15:26 | comment | added | HMS Tree | Updated: tried use following code (udpated in question) to get errors, but it seems like no error occured. | |
| Jan 12, 2025 at 15:17 | history | edited | HMS Tree | CC BY-SA 4.0 |
added 6 characters in body
|
| Jan 12, 2025 at 15:14 | comment | added | Some programmer dude |
First of all, always check for failure. In your case check what freopen returns. If it fails, use strerror to get a printable string of the error from errno. And to emphasize what others have said, use standard C++ facilities for all your file input and output.
|
|
| Jan 12, 2025 at 15:11 | comment | added | HMS Tree | ofstream do not work either. Visual Studio is not available on ICPC World Finals docs.icpc.global/worldfinals-programming-environment | |
| Jan 12, 2025 at 15:06 | comment | added | Pepijn Kramer | Recommendation : fully switch to "visual studio community edition" it is much more easy to use than "visual studio code" | |
| Jan 12, 2025 at 15:04 | comment | added | Pepijn Kramer |
Why do you think you should use freopen (and std::cin, std::cout)? Use std::ofstream learncpp.com : 28.6 — Basic file I/O
|
|
| S Jan 12, 2025 at 15:00 | history | asked | HMS Tree | CC BY-SA 4.0 | |
| S Jan 12, 2025 at 15:00 | history | created from staging ground | Graduated from staging ground post. |