Why system CLS is used?


Computing Commands in CLS

In computing, CLS (for clear screen) is a command used by the command-line interpreters on various operating systems to clear the screen or console window of commands and any output generated by them.

  • CLS: This command is used to clear the screen or wipe out everything written on the screen.

File Related Commands in C Programming

  • fread and fwrite: The functions fread and fwrite are used for reading/writing data from/to the file opened by the fopen function. These functions accept three arguments. In case of success, fread/fwrite return the number of bytes actually read/written from/to the stream opened by fopen function.

  • fseek and ftell in C:

    • ftell(): Used to store the current file position.
    • fseek(): Used to relocate to one of the following:
    • A file position stored by ftell()
    • A calculated record number (SEEK_SET)
    • A position relative to the current position (SEEK_CUR)

Examples of File Manipulation in C Programming

Example of feof with fread

The following example shows the usage of feof() function.

#include <stdio.h>
int main () {
   FILE *fp;
   int c;

   fp = fopen("file.txt","r");

   if(fp == NULL) {
      perror("Error in opening file");
      return(-1);
   }

   while(1) {
      c = fgetc(fp);
      if( feof(fp) ) {
         break ;
      }
      printf("%c", c);
   }

   fclose(fp);
   return(0);
}

Captionless Image Output

Explanation: The output of the given code is "Hii".

Struct in Programming

A struct in the C programming language is a composite data type declaration that defines a physically grouped list of variables under one name in a block of memory, allowing the different variables to be accessed via a single pointer or by the struct declared name which returns the.

Lascia un commento