Soluții

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 fix unresponsive Start and Taskbar on W11

If you have a device enrolled in the Windows 11 Dev or Beta Channels of the Windows Insider Program, you probably noticed that during the last update to build 22449 and build 22000.176, the Start menu and Taskbar were unresponsive, and Settings and other elements of the OS were not loading.

According to Microsoft, this issue occurred because of a server-side deployment (which it’s not detailing) and canceled that deployment. In the case that you came across this problem, the company has issued a workaround to get Windows 11 back to normal.

[mai mult...]

How to Connect Your Mac to Any VPN (and Automatically Reconnect)

Macs have built-in support for connecting to the most common types of VPNs. If you want to ensure your Mac is automatically reconnected to your VPN or connect to an OpenVPN VPN, you’ll need a third-party app. This process is similar whether you’re using Windows, Android, iPhone, iPad, or another operating system. macOS provides a menu bar icon for controlling the VPN connection.

[mai mult...]

How to use the mount command in UNIX

The mount command tells the UNIX operating system that a file system is ready to use i.e. mount a file system at a particular point in the system’s file system hierarchy.

The syntax is as follows:

mount /dev/XYZN /mount/point
WARNING! The mount commands require root user privilege or the corresponding fine-grained privilege, unless the file system is defined as “user mountable” in the /etc/fstab file.
Examples

Mount /dev/sda5 (Linux partition) in /data directory:

mkdir /data
mount /dev/sda5 /data
df -H
ls /data
cd /data

Mount /dev/aacd0s1g (FreeBSD UNIX partition) in /salesdata directory:

mkdir /salesdata
df -H
mount /dev/aacd0s1g /salesdata
ls /salesdata
cd /salesdata

Mount /dev/dsk/c1t4d0s0 under Solaris UNIX at /data2, enter:

mkdir /data2
mount /dev/dsk/c1t4d0s0 /data2

To remove mount point run:

umount /salesdata

To mount all file systems listed in /etc/fstab, enter:
mount -a
[mai mult...]