Posts

C Program to open and write to a text file using fprintf.

  C Program to  open and write to a text file using fprintf. # include <stdio.h> #include <conio.h>  # include <string.h>   void  main( ) {    FILE *fptr ;   char data[100] = “Welcome to Code Hub-A Computer Science Portal for Engineering UG and PG students";  fptr = fopen("program.c", "w") ;  if(fptr == NULL )     { printf( "program.c file failed to open." ) ;     }     else     {  printf("The file is now opened\n") ;   i f (strlen(data) > 0 )         {  fputs(data,  fptr ) ;      fputs("\n",  fptr ) ;         }     fclose( fptr ) ; printf("Data successfully written in file \n"); printf("The file is closed.") ;     }      getch();   }

C Program to open and write to a text file using fprintf.

  C Program to  open and write to a text file using fprintf. #include <stdio.h> #include <conio.h>  #include <stdlib.h>   void   main() {    int number;    FILE *fileptr; fileptr = fopen("D:\\program.txt","w");    if( fileptr == NULL)    {       printf("Error in file !");         exit(1);                } printf("Enter number: "); scanf("%d",&number); fprintf( "fileptr %d",number);    fclose( fileptr );      getch();    }  

C Program to open and write a text file.

  C Program to  open and write a text file.   #include <stdio.h> #include <conio.h>    void  main() {    FILE *fptr;  if (fp = fopen("Resume.txt", "wb")) {  printf("File opened successfully and write in binary mode .");    }    else    printf("Error!");    fclose(fptr);    getch();

C Program to shut down or turn off your machine or computer

  C Program to shut down or turn off your machine or computer #include <stdio.h> #include <stdlib.h>   int main() {    system("C:\\WINDOWS\\System32\\shutdown /s");      return 0; }

C Program to print Internet Protocol (IP) address in your machine.

  C Program to print Internet Protocol (IP) address in your machine. #include<stdio.h> #include<stdlib.h> int main() {    system("C:\\Windows\\System32\\ipconfig");        return 0; }