0

I am working through the CS50 course and downloaded the cs50.h file into the same directory as my cs50.c file.

However, I am receiving a fatal error cs50.h: No such file or directory when i include the cs50.h header in my program

#include <cs50.h>

Any suggestions, please? I'm using Code::Blocks 20.03

Cheers

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
john_joseph
  • 9
  • 1
  • 2

3 Answers3

1
  • if it's not from an official lib you can't use <> you need to use "". But it's not a fatal error it doesn't really matter.
  • if it's in another directory you need to specify the path like so include "/file/anotherFile/cs50.h".
  • if it's your current directory you can write it like that it might fix the problem "./cs50.h"

hope it helped you !

Tsirsuna
  • 130
  • 2
  • 16
0

Try running your file in the cs50 workspace. You would've set up a repository upon beginning the course.

L S
  • 1
0

for this I changed my compiler to clang and included cs50 as #include "cs50.h" instead of #include <cs50.h> and it worked fine. need to include all c files in the task, eg in vs code, tasks.json file should look like:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang.exe build active file",
            "command": "C:\\mingw64\\bin\\clang.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${workspaceFolder}\\*.c",
                "-o",
                "${workspaceFolder}\\main.exe"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: C:\\mingw64\\bin\\clang.exe"
        }
    ]
}
Hzine
  • 105
  • 1
  • 9