buffer in c

    0

    0

    ATISHAY JAIN 20BCY10153

    The code in question is a program that prompts for a password, and if the password is correct, it prints "Correct Password". If the password is incorrect, it prints "Wrong Password". If the user wants to give themselves root or admin rights, they need to enter the correct password.

    #include <stdio.h>
    #include <string.h>
    
    int main(void)
    {
      char buff[15];
      int pass = 0;
    
      printf("\n Enter the password : \n");
      gets(buff);
    
      if(strcmp(buff, "thegeekstuff"))
      {
        printf ("\n Wrong Password \n");
      }
      else
      {
        printf ("\n Correct Password \n");
        pass = 1;
      }
    
      if(pass)
      {
        /* Now Give root or admin rights to user*/
        printf ("\n Root privileges given to the user \n");
      }
    
      return 0;
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.