15 Ocak 2022

c++ içinde fopen read problemi

ile Yunus KALDIRIM

Elimde olan bir c++ source code için Visual Studio 2022 sürümünde debug yaparken karşılaştığım aşağıdaki semptompların çözümünü içermektedir. fopen komutunun çalışmadığını sanmama neden olan bu hata tamamen IDE’nin dosyayı hangi klasörde aradığı ile ilgiliymiş.

Symptoms:

  • Fopen – No such file or directory in C
  • fopen no such file or directory but file exists c
  • Getting a No such file or directory on fopen()
  • Using fopen on a directory on windows
  • fopen not working windows
  • fopen fails mysteriously under Windows
  • fopen() does not open file. Why?
  • FILE *f = fopen(filename, “r”);

Solution:

a) if you are giving a constant filename with directory it has interesting problems

you need to add “.” infront of the “/”

you need to use double slashes in windows eg: “C:\\folder1\\folder2\\filename.txt”

you can use “/” in windows and linux eg: “C:/folder1/folder2/filename.txt”

b) if you are not giving a constant folder with filename and you use arg[1] as variable you need to put file under the “project folder” not debug or release folder while debugging. This was my case!

buy kamagra 100mg