Why this code does not print file names?

Does anybody know why this code does not print filenames but HEX number 0012FA80 - repetitively? It is address of the class member. This is example from MSDN page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int findFiles()
{
   WIN32_FIND_DATA search_data;
   memset(&search_data, 0, sizeof(WIN32_FIND_DATA));
   HANDLE handle = FindFirstFile(L"c:\\*.bat", &search_data);

   while(handle != INVALID_HANDLE_VALUE)
   {
      std::cout<<"\n"<<search_data.cFileName;
      if(FindNextFile(handle, &search_data) == FALSE)
        break;
   }

   FindClose(handle);
   return 0;
};
Last edited on
This method uses Boost library. Did you install it and include related headers?
Last edited on
I have downloaded boost_1_55_0.zip just to see what it contains. There are some jam files and hpp. Does not look like C++ . I probably will not use it.
It is absolutely C++. Boost is pretty much the C++ library of them all - a large part of the C++11 and C++14 standard libraries were originally part of Boost. The jam files are used to compile the code, they aren't C++ (don't worry about them for most things), while *.hpp is another header file format (like *.h, *.H, *.hxx, and others). It is a mostly header-only library, so don't worry about needing to compile anything.
Yeah but the boost looks hard to use for me. I don't know to use it. Also I cannot use C++11 I probably have C++03 because of Visual Studio C++ 2004 Express which I am depended and cannot upgrade.
Its actually quite easy to use. Also, a common use of the Boost libraries is as an alternative to the C++11 standard library, so that you can use it without your compiler supporting C++11.

For your thing, you will be using (I presume) Boost.Filesystem, which does need compilation, so that can be a bit complicated (though still surprisingly easy). To learn, just follow this link: http://www.boost.org/doc/libs/1_55_0/more/getting_started/windows.html

Also, Visual Studio 2004? I didn't even know that existed...
typo, sorry vs 2010
I will try it. Thanks
Last edited on
How to configurate the Visual Studio C/C++ Additional Include Directories exactly?

I tried

C:\C++\boost_1_55_0\libs\accumulators\example;$(BOOST_ROOT);%(AdditionalIncludeDirectories)

and I am getting error:
s:\c++\lambda_boost\lambda_boost\lambda_boost.cpp(2): fatal error C1083: Cannot open include file: 'boost/libs/accumulators/lambda/lambda.hpp': No such file or directory
Last edited on
Instead of $(BOOST_ROOT) better use the path to boost directly.
$(BOOST_ROOT) is a global environment setting (which i don't consider as reliable)

Use set in you command line evironment to find out what's the real path of $(BOOST_ROOT) is (if any)
Coder: there is no boost item in the system path variable.

I also asked where they set the BOOST variable. The manual seems incomplete, they do not mention this. They say they use BOOST but not where they set it. Also I checked system variables if they mean system variable, but there is not any. I have no idea if this should be done manually to the system configuration or what.
Last edited on
Also does anybody know why this code does not print filenames but HEX number 0012FA80 - repetitively? It is address of the variable. This is example from MSDN page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int findFiles()
{
   WIN32_FIND_DATA search_data;
   memset(&search_data, 0, sizeof(WIN32_FIND_DATA));
   HANDLE handle = FindFirstFile(L"c:\\*.bat", &search_data);

   while(handle != INVALID_HANDLE_VALUE)
   {
      std::cout<<"\n"<<search_data.cFileName;
      if(FindNextFile(handle, &search_data) == FALSE)
        break;
   }

   FindClose(handle);
   return 0;
};
h4ever wrote:
I also asked where they set the BOOST variable. The manual seems incomplete, they do not mention this. They say they use BOOST but not where they set it. Also I checked system variables if they mean system variable, but there is not any. I have no idea if this should be done manually to the system configuration or what.
Boost Getting Started Docs wrote:
The path to the boost root directory (often C:\Program Files\boost\boost_1_55_0) is sometimes referred to as $BOOST_ROOT in documentation and mailing lists .


As for the win32-specific example, you need to consider that cFileName is a TCHAR. This means that it could be a wide string, which cout doesn't know how to print (AFAIK). Instead, either try using wcout or make sure to compile using ASCII rather than UNICODE (consult the documentation on how to do this). Of course, I might be wrong - personally I don't use VS often.
Last edited on
NT3: The quoted part of the documentation says that it is refered as $BOOST_ROOT

Do you see somewhere in the string: ";$(BOOST_ROOT);%(AdditionalIncludeDirectories)" word "$BOOST_ROOT" ??? I don't.

I simply thought the $BOOST_ROOT is used by code.

In Configuration Properties > C/C++ > General > Additional Include Directories, enter the path to the Boost root directory, for example

They did not written where exactly this should be written so I thought it is in the same way as in Windows variable PATH=c:/;c:/programs;c:/next.programs;c:\etc. Sounds like can be written anywhere. It also could mean do delete the line and then written the path there, which would be obviously wrong.

They simply could say "replace the word $(BOOST_ROOT); by $(your path)" or "replace the word BOOST_ROOT by your path" depending on what is correct.

Last edited on
Topic archived. No new replies allowed.