How to read data from files with C++

  1. Include the fstream header file with using std::ifstream;
  2. Declare a variable of type ifstream
  3. Open the file
  4. Check for an open file error
  5. Read from the file
  6. After each read, check for end-of-file using the eof() member function.

Example:

#include <iostream>
using std::cerr;
using std::cout;
using std::endl;
#include <fstream>
using std::ifstream;
#include <cstdlib> // for exit function
// This program reads values from the file 'example.dat'
// and echoes them to the display until a negative value
// is read.
int main()
{
   ifstream indata; // indata is like cin
   int num; // variable for input value
indata.open("example.dat"); // opens the file
   if(!indata) { // file couldn't be opened
      cerr << "Error: file could not be opened" << endl;
      exit(1);
   }
indata >> num;
   while ( !indata.eof() ) { // keep reading until end-of-file
      cout << "The next number is " << num << endl;
      indata >> num; // sets EOF flag if no value found
   }
   indata.close();
   cout << "End-of-file reached.." << endl;
   return 0;
}
[mai mult...]

How to unlock a locked account in Windows 10

  • Log in to your main windows account (administrator )
  • Open ” run ” command

  •  type in ” lusrmgr.msc ” in the run command box and press enter

  • double click on the ” Users ” folder

  • then double click on the account which is locked ; in our case ” User “

  • uncheck the “account is locket out ” box and press OK

[mai mult...]

How to create a secure folder in Windows 10

  1. Open the cmd.exe in administrator mode
  2. Search the folder you want to secure : for example our folder will be named “test”
  3. Then type in cmd.exe the following lock command : Cacls “D:\test” /E /P everyone:n ; After that your folder is secured/locked
  4. Then when you want to open/move/delete the “test” folder you will need administrator privillege.
  5. To unlock the folder, type in cmd.exe the following unlock command : Cacls “D:\test” everyone:; After that your folder returns to  the initial form
[mai mult...]