I have a program in C that changes a decimal number into a binary.
int main()
{
int n, c, k;
printf("Enter an integer\n");
scanf("%d", &n);
printf("%d in binary is:\n", n);
for (c = 31; c >= 0; c--)
{
k = n >> c;
if (k & 1)
printf("1");
else
printf("0");
}
printf("\n");
return 0;
}
It takes data from what I write in terminal but I would like it to get the data from integers.txt file, which is something like this:
101
34
-11
1,5
lorem ipsum
33.33333
10022
The program should get the integers from the txt file and perform an action to change them into the binary, and at the same time should warn that 1,5 or lorem ipsum are not integers, should not perfom the action on them but should continue to convert other integers. And I'm a bit stuck on how to properly get integers from .txt file and process convert action on them.