Ok I came back to this problem after holidays and here it is what I made for first problem:
Code:
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
uint8_t a, b, c, d, m;
cout << ("Enter character which bits will be inverted:");
cin >> a;
cout << ("Enter starting bit range to change:");
cin >> c;
cout << ("Enter last bit range to change:");
cin >> d;
m = ~0;
m = m >> (8-(d-c+1));
m = m << (c-1);
b = a ^ m;
cout << b;
return 0;
}
I don't know why it doesn't work, with fixed numbers it works like a charm but with variables it just returns number provided by user. What I did wrong?