4 Write a C program that reads a line of input from the standard input and then

4 write a c program that reads a line of input from

This preview shows page 3 - 4 out of 4 pages.

In C, the last character in a string must always be the null character "\0".4.Write a C program that reads a line of input from the standard input and then reverse the line. Finally print out the reversed line on the standard output.You may want to use the standard function strlento find out the number of characters in a character array. By typing the command man -s 3 strlen, you will find that you must include string.hheader file.You may also want to use C's for-loop for this question. The following example shows how to loop through an array:
Image of page 3
n = strlen(line); for ( i = 0; i < n; ++i ) { c = line[i]; } where n is an integer variable containing the number of characters in the char array line , i is an integer variable which acts as the loop index, c is a char variable, and line is a character array. Lab Assignment: 1.Explain what the current directoryis and what the home directoryis. Demonstrate how to set your current directory to a particular directory and how to find out your current directory and how to set your current directory to your home directory.2.Demonstrate that you can create a simple C program (eg hello.c) witha text editor from command line (not with a GUI tool) and compile it with gcc and generate executable with appropriate name (eg hello). 3. Complete Exercise 4 in C Programming Exercises. This lab assignment must be submitted to the LMS. The deadline of submission is given in the Unit Information Page of the LMS. You must adhere to the instructions in the document titled The Requirements for Documenting and Submitting Lab Assignments when preparing and submitting lab assignments. Dr Hong Xie Unit Coordinator Last update: Tuesday, 24 April 2018 Document author: Dr. H. Xie , Unit Coordinator, ICT374 Operating Systems and Systems Programming Last Modified: Tuesday, 24-Apr-2018 13:56:43 AWST Disclaimer & Copyright Notice © 2018 Murdoch University This document is relevant for 2018 only
Image of page 4

You've reached the end of your free preview.

Want to read all 4 pages?

  • One '14
  • home directory, current directory, C standard library

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture