Count Characters, Lines, and Words in a File in C

Bhanu Priya
Updated on 31-Aug-2021 12:58:48

16K+ Views

A file is a physical storage location on disk and a directory is a logical path which is used to organise the files. A file exists within a directory.The three operations that we can perform on file are as follows −Open a file.Process file (read, write, modify).Save and close file.ExampleConsider an example given below −Open a file in write mode.Enter statements in the file.The input file is as follows −Hi welcome to my world This is C programming tutorial From tutorials PointThe output is as follows −Number of characters = 72Total words = 13Total lines = 3ProgramFollowing is the C ... Read More

Print Hollow Rectangle Star Pattern in C

Bhanu Priya
Updated on 31-Aug-2021 12:55:09

14K+ Views

Here, we will print hollow rectangle star(*) pattern by using for loop in C programming language.Consider an example given below −InputEnter number of rows: 5OutputThe output is as follows −***** *    * *    * *    * *****AlgorithmAn algorithm is given below to explain how to print hollow rectangle star(*) pattern by using for loop.Step 1 − Input number of rows to print at runtime.Step 2 − Use outer for loop for rows from 1 to N.for(i=1; i

Remove a Line from a File in C

Bhanu Priya
Updated on 31-Aug-2021 12:51:33

10K+ Views

A file is a physical storage location on disk and a directory is a logical path which is used to organise the files. A file exists within a directory.The three operations that we can perform on file are as follows −Open a file.Process file (read, write, modify).Save and close file.AlgorithmAn algorithm is given below to explain the C program to remove a line from the file.Step 1 − Read file path and line number to remove at runtime.Step 2 − Open file in read mode and store in source file.Step 3 − Create and open a temporary file in write ... Read More

Store Even, Odd, and Prime Numbers into Separate Files in C

Bhanu Priya
Updated on 31-Aug-2021 12:49:33

4K+ Views

A file is a physical storage location on disk and a directory is a logical path which is used to organise the files. A file exists within a directory.The three operations that we can perform on file are as follows −Open a file.Process file (read, write, modify).Save and close file.ProgramFollowing is the C program to store even, odd and prime numbers into separate files − Live Demo#include #include /* Function declarations */ int even(const int num); int prime(const int num); int main(){    FILE * fptrinput,    * fptreven,    * fptrodd,    * fptrprime;    int num, success; ... Read More

Get Accelerated Networking Status of Azure VM Using PowerShell

Chirag Nagrekar
Updated on 31-Aug-2021 11:42:05

727 Views

From the Azure Portal, we can find the Accelerated Networking (AN) status from the networking blade.To get the AN settings on the VM, we need to first retrieve the NIC information because it is set on it. We have the VM named ‘TestVM’ and we will retrieve its NIC information.PS C:\> $vm = Get-AzVM -Name TestVMTo get the NIC associated with the VM, $nicname = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1]We need to retrieve the NIC settings to get the AN setting.$nicsetting = Get-AzNetworkInterface -ResourceGroupName $vm.ResourceGroupName - Name $nicnameTo get the AN settings, use the EnableAcceleratedNetworking property.$nicsetting.EnableAcceleratedNetworkingIf you want to retrieve the AN settings on ... Read More

Retrieve MSI Package Product Code Using PowerShell

Chirag Nagrekar
Updated on 31-Aug-2021 11:28:17

14K+ Views

You can retrieve the MSI installed packaged product code on the windows OS using PowerShell with Get-Package or Get-WmiObject command.In this example, we will retrieve the product code of 7-zip.Get-Package -Name '7-Zip 19.00 (x64 edition)' | fl *You can use the tagid or mentioned properties to filter the product code.To retrieve the package from the remote computer using the Get-Package method, use InvokeCommand.Invoke-Command -ComputerName TestMachine -ScriptBlock{    (Get-Package -Name '7-Zip 19.00 (x64 edition)').TagID }Another way to retrieve the product code is by using the WMI method as shown below.PS C:\> $product = Get-WmiObject win32_product | where{$_.name - eq "7-Zip 19.00 (x64 ... Read More

Get Azure VM Username Using Azure CLI in PowerShell

Chirag Nagrekar
Updated on 31-Aug-2021 11:13:16

827 Views

To get the Azure VM username using Az CLI, we need to use the below command.PS C:\> az vm show -n AzVM -g ResourceGroup --query '[osProfile.adminUsername]' -otsvThe above command will retrieve the Azure VM username. You can also use the below command to retrieve the Azure VM username without knowing the resource group name.PS C:\> az vm list --query "[?name=='vmname'].osProfile.adminUsername" -otsvBefore running the above commands, make sure that you are connected to the Azure cloud and the specific Azure Subscription.

Get Azure VM Size Using Azure CLI in PowerShell

Chirag Nagrekar
Updated on 31-Aug-2021 11:12:45

2K+ Views

To get the Azure VM size using Azure CLI, we first need to make sure that the Azure account is connected to the specific subscription for the VM that we need to retrieve the VM size.To get the specific Azure VM size, we need to first retrieve the VM details and then need to run the JMESPATH query to retrieve the VM size.az vm show -n VMname -g ResourceGroupName --query '[hardwareProfile.vmSize]' -otsvyou can also retrieve the size of the VM without resource group name, using “az vm list” command.az vm list --query "[?name=='AzVM'].hardwareProfile.vmSize" -otsvRead More

Get Azure VM Activity Logs Using PowerShell

Chirag Nagrekar
Updated on 31-Aug-2021 11:09:31

2K+ Views

To get the Azure VM activity logs with PowerShell, we need to use the Get-AzLog command. Before running, AZ commands make sure that you are connected to the Azure Account using (ConnectAzAccount) and the subscription (Set-AzContext).We have the below TestVM, we need to retrieve activity logs and we need its resource id. We will get the resource ID using, PS C:\> $vm = Get-AzVM -VMName TestVMPS C:\> $vm.IdWe need to use this ID in the Get-AzLog command to retrieve the activity logs.PS C:\> Get-AzLog -ResourceId $vm.IdIt will provide all the azure events for that specific resource group and you can ... Read More

Get Windows Authentication Settings Using PowerShell

Chirag Nagrekar
Updated on 31-Aug-2021 11:07:33

1K+ Views

To get the windows server authentication setting using PowerShell, we can use the below command on the local server.PS C:\> Get-ChildItem WSMan:\localhost\Service\Auth | Select name, valueOutputName              Value ----              ----- Basic             false Kerberos          true Negotiate         true Certificate       false CredSSP           false CbtHardeningLevel RelaxedTo get the same settings on the remote servers, use the below command.Invoke-Command -ComputerName TestMahchine1, TestMachine2 - ScriptBlock {    Get-ChildItem WSMan:\localhost\Service\Auth } | Select PSComputerName, Name, Auth

Advertisements