B1: Write a C/C++ script to display all logged in users.
Program:
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<iostream>
using
namespace std;
main()
{
cout<<"*****PROGRAM
TO SHOW LOGGED IN USER AND NUMBER OF LOGGED IN USER****\n";
cout<<"LOGGED
IN USERS ARE:-\n";
cout<<system("who
-u");
cout<<"NUMBER
OF LOGGED IN USERS ARE :-\n";
cout<<system("
who -u| wc -l");
}
Output:
shubham@Inspiron-1545:~$
g++ assign1.cpp
shubham@Inspiron-1545:~$
./a.out
The Real User Name is cl2
0 comments:
Post a Comment