-3

The code was intended to cout the day of week. Using Visual Studio 2017 and the version is 15.8.280 10.2050

Code was copied from here: https://howardhinnant.github.io/date/date.html

The code didn't run and showed the errors mentioned already and also that Name must be a namespace name and "weekday" is undefined.

My skills are minimal at this point. Just starting to understand what things are called and sort of how they fit together.

Also, what are the things that are after #include called? some are header files right? but what about the others like fstream etc. ?

Thanks!

Many searches online found no answer directly. There were some related but nothing that explained it in a way i could understand.

#include "date.h"
#include <iostream>

int
main()
{
    using namespace date;
    std::cout << weekday{ August / 22 / 2019 } << '\n';
}
humbleB73
  • 21
  • 4
  • 1
    Without knowing the original article you read it's difficult to understand what you are trying to achieve, but I think you want to download the date library from Howard Hinnant which is used as basis for the date library in the future versions of C++: https://github.com/HowardHinnant/date – CuriouslyRecurringThoughts Aug 23 '19 at 21:50
  • 1
    The error means you don't have the include file `date.h` in the standard search directories. You either need to specify where it is or include the directory in your build settings. – NathanOliver Aug 23 '19 at 21:53
  • Maybe youb should rework your question. Be more precise and ask your questions at the end, maybe Like this: It was intended to show the day of week. Using Visual Studio 2017, Version 10.0.17134.0 After trying to get tm and time_t stuff to work. Also, what are the things that are after #include called? some are header files right? but what about the others like etc. ? – Christian Aug 23 '19 at 22:00
  • Did you put the `date.h` file in the same exact folder as your project? The contents of the file are here: https://raw.githubusercontent.com/HowardHinnant/date/master/include/date/date.h – drescherjm Aug 23 '19 at 22:24
  • `#include`'s job is really simple. Whatever file you list after it in the quotes or angle brackets is pasted into the file being compiled. The combined file is then compiled. Some reading on that: [How does the compilation/linking process work?](https://stackoverflow.com/questions/6264249/how-does-the-compilation-linking-process-work). You could put any file--a header, source file that should be compiled, a CSV file, a Word document, a picture of your sweet ol' granny, anything--and it will be pasted in and compiled. – user4581301 Aug 23 '19 at 22:28
  • Obviously if it's not valid C++ code or otherwise protected, I've `#include`ed stripped-down CSV files into array initializers in the past, it won't compile, but you can `#include` anything. fstream is simply a file named fstream that is a bog-standard C++ header file without an extension. – user4581301 Aug 23 '19 at 22:31
  • 1
    Still more reading: [What is the difference between #include and #include “filename”?](https://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename). There is a LOT of reading involved in learning C++. I strongly recommend getting and reading [a good reference book or library of books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – user4581301 Aug 23 '19 at 22:34
  • Got it. Thanks for all the help and suggestions, and the header file. – humbleB73 Aug 24 '19 at 01:10

2 Answers2

4

date.h refers to this library:

https://github.com/HowardHinnant/date

You can run this on Windows by simply downloading this one header.

This header (with some minor modifications) has been voted into the C++20 spec.

Howard Hinnant
  • 206,506
  • 52
  • 449
  • 577
0

I beleive you need the header file in your project directory in order to use it.

As for your other question:

#include "file.h" //this is including a header file
#include <cstdlib> //this is including a function library file.

Some of them come standard, and some you have to download from opensources to use them.

When you get the "No such file in directory" error its because its not found within the scope of your project in VS or Netbeans.

Krausladen
  • 138
  • 10