Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Int40* loadCryptoVariable(char *cryptoVariableFilename) Returns: A pointer to an

ID: 3604412 • Letter: I

Question

Int40* loadCryptoVariable(char *cryptoVariableFilename)

Returns: A pointer to an Int40 array of 40 random hexadecimal digits read in from the cryptoVariableFilename. Returns NULL if there is an error during initialization of the cryptoVariable or in the file I/O.

I just need the function made for Int40* loadCryptoVariable(char *cryptoVariableFilename). It should not include a main() and an example of how it will be used is

void kw26Print(Int40 *p)
{
int i;

if (p == NULL)
{
printf("(null pointer) ");
return;
}

for (i = MAX40 - 1; i >= 0; i--)
printf("%x", p->digits[i]);
printf(" ");
}

int main(void)
{
Int40 *p;

// Load crypto variable from the file named cryptoVarFile
kw26Print(p = loadCryptoVariable("cryptoVarFile"));

return 0;

}

output is 1319df0463129a3245ac0963f78eca0137e42fa0

Explanation / Answer

here is your function : ------------------->>>>>>>>>>>>>>>>>>>

#include<stdio.h>

/*Function to load 40 hexadecimal to int40 */
int40 *loadCryptoVariable(char *c){
/*file pointer to get the file open*/
FILE *fp;
int40 *p;/*a pointer of int40 in which we store the value and return it*/
int i = 0;
fp = fopen(c,"r");/*opening the file*/
if(fp == NULL){/*checking of file not open error and returning NULL pointer*/
  p == NULL;
  return p;
}
else{
  while(fscanf(fp,"%x",p->digits[i]) != EOF){/*reading and storing value in digits of int40*/
   i = i+1;
  }
  return p;/*returning the pointer of int40*/
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote