You can use the FindFirstFile function[^] to start a search for files in a directory tree. As you get each file's name you can then read its contents and search for the text. Do not be surprised if it takes a lot of time.
Sorry Sir, I think I have not explained my question correctly.I am looking for function which gets the string(will be equal irrespective of the file size) of all files present in the computer and compares with the string which I have defined in my program.More precisely I am looking for a program which searches for the "strings" irrespective of their names.
Yes I understand your question. And the way to do it, is to get the list of all files in your target set, and then read each file in turn in order to find the string. You can use some the strXXX functions[^] to speed up the searching.
Sir, What if I do if I run the executable on another computer.I have only "C:\\ and D:\\" drives if I run the executable on another computer which has "C:\\ D:\\ E:\\ " drives my code ultimately fails .How can I get the list of all files on the computer on which my executable runs.I sincerely thank you for giving me the excellent link for speed up my searching.
You should move your find processing to a separate function and call that with the root path you wish to search. You can then call that recursively each time you find a directory, something like:
void ProcessFiles(string root, string directory)
string searchPath = // root plus directory plus mask// start the find loop// if next filename = "." or ".." continue// if next entry is a directory // ProcessFiles(searchPath, directory.name);// ...
The Button is a standard Windows control that can be used in a Win32 or MFC application. The MFC Button Control[^] is an MFC class that 'wraps' the standard Button, but can only be used in MFC applications.
2>C:\Program Files\Microsoft SDKs\Windows\v6.0A\\include\rpcndr.h(154) : warning C4114: same type qualifier used more than once
2>C:\Program Files\Microsoft SDKs\Windows\v6.0A\\include\rpcndr.h(154) : error C2632: 'char' followed by 'char' is illegal
2>C:\Program Files\Microsoft SDKs\Windows\v6.0A\\include\rpcndr.h(154) : warning C4091: 'typedef ' : ignored on left of 'unsigned char' when no variable is declared
Such things may happen when including header files in the wrong order, required header files has not been loaded, or are skipped due to exclusions. Because we don't know the other headers file that might be involved, it can't be answered for now.
A common problem is the inclusion of winsock2.h. This must be included before windows.h. I mention it here beacuse RPC is network related.
If this does not help you should try to find out the correct order by inspecting the header file inclusion tree. You can generate an include file tree by editing your project settings (Configuration Properties - C/C++ - Advanced - Show Includes).
Inspect the line of error (154 in rpcnhdr.h) to know which definitions trigger the error. Then try to find these definitions in header files included before that.
When you use ATL, then your application is not a non-ATL one.
The first error message is "same type qualifier used more than once". So byte has been already defined.
The next one "'char' followed by 'char' is illegal" indicates that byte has been probably defined using a #define statement so that the compiler sees
The third error is just based on the previous one.
So the goal is to find the previous definition of byte and check if the definition can be suppressed or the header file containing it might be included later. That might be some work because atlbase.h includes a lot of other files. I did a quick search but did not found it. But you should better perform this search with your files because they may change with the Visual Studi and the SDK versions.
Sir, I need to create "string" as an output using my formatted data.
To achieve this I did make use of "sprintf" function.But when building a solution using visual studio I get "C4996" error.
Here is the error message which I get:
Severity Code Description Project File Line Error C4996 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 155
to disable all depreciation I've used this preprocessors as per my compiler's suggestion
_CRT_SECURE_NO_WARNINGS must be defined before the header files that use the macro are included. So put it on top of your source file before including any header files.
To set it for all files of a project, add it on top of stdafx.h (when using that) or add it to the preprocessor definitions of your project settings (Configuration Properties - C++ - Preprocessor - Preprocessor Definitions).
Decreasing the warning level does not help here because the warning is treated as an error. To treat them as warnings, set SDL Checks to No in your project settings (Configuration Properties - C++ - General).
Another option is disabling the warning by using a pragma statement:
#pragma warning(disable : 4996)
This is useful when using those deprecated functions only a few times because they can be disabled on function level: