ASCII value for char or Int value for ASCII C

Asked

Viewed 797 times

0

Guys, I need to search for a value found by a rand in a file, I’m having a lot of problems because the rand returns me an integer and to fetch character in a file the fgetc me returns an integer corresponding to the ASCII of the character. I am unable to convert the integer to its ASCII value or convert the found ASCII number to char.

Can anyone give me a light? Thank you

  • 1

    Show what you’ve done and indicate where the problem is.

  • tried to use fscanf ?

1 answer

0


You can create a char type variable, and match it to the integer value, then just compare the char to the file value.

char c;

c = 125;

This is because the char type is a 1 byte variable whose value goes from 0~255.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.