_lab3.pdf

  • Uploaded by: Muhammad Tehseen Khan
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View _lab3.pdf as PDF for free.

More details

  • Words: 155
  • Pages:
Lab2: Static Variables and Error Reporting Complete the following tasks and show its execution for different inputs. In your lab report, show the program code and execution. Show execution using a transcript or screenshots.

Task 1: Write a C program that prints errorno when the user tries to open a write protected file. Also print the descriptive error using perror(). Task 2: In a C program try to close a file that was never opened. Show the errorno and error message that it generates. Task 3: What would be the output of the following program? Please explain? #include <stdio.h> void getPrint() { int var = 0; static int staticVar = 0; var += 10; staticVar += 10; printf("var = %d, staticVar = %d\n", var, staticVar); } int main() { int i; for (i = 0; i < 10; ++i) getPrint(); }

Task 4: What is the difference between a static and non static global variables.

More Documents from "Muhammad Tehseen Khan"

Cc_w3_aws_basic_infra_.ppt
December 2019 3
Assignment 1.docx
December 2019 13
_lab3.pdf
December 2019 2
Imf Final Project
May 2020 1
1-coal.pdf
November 2019 19