i have this assignment, i need to read binary from a file and convert it to hex...
the format of the file is, for example
6 3
101011
001010
110101
6 and 3 are the length and the width and the rest are the binary numbers... now i have to read the file line by line... if the numbers are less than 8... i have to add 2 0's at the beginning then convert to hex... if there are 13 numbers, i have to add 3 0's at the beginning then convert to hex and so and so forth...
i'm reading the file using stdin (a1 < text.txt)
i can't use arrays btw... how can i read the required amount of numbers... if i use 8 number variables... it will start reading the next line....
the format of the file is, for example
6 3
101011
001010
110101
6 and 3 are the length and the width and the rest are the binary numbers... now i have to read the file line by line... if the numbers are less than 8... i have to add 2 0's at the beginning then convert to hex... if there are 13 numbers, i have to add 3 0's at the beginning then convert to hex and so and so forth...
i'm reading the file using stdin (a1 < text.txt)
i can't use arrays btw... how can i read the required amount of numbers... if i use 8 number variables... it will start reading the next line....