Given two strings A and B, how would you find out if the characters in B were a subset of the characters in A?
What's the difference between const char *p, char * const p and const char * const p?
Syntax in C
qualifier:
volatile
const
storage-class:
auto extern
static register
type:
void char short
int long float
double signed unsigned
enum-specifier
typedef-name
struct-or-union-specifier
Access non const member varible inside a const member function
class MyClass {
public:
void F() const {
const_cast(this)->c = 10;
//c = 10;
}
private :
int c;
};
Other solution is mutable.
How to add two numbers without using the plus operator?
What are the common causes of pointer bugs?
What is the difference between malloc() and calloc()?
Convert the decimal number to any base (binary, hex, oct etc...)
#include
int main()
{
decimal_to_anybase(10, 2);
decimal_to_anybase(255, 16);
getch();
}
decimal_to_anybase(int n, int base)
{
int i, m, digits[1000], flag;
i=0;
printf("\n\n[%d] converted to base [%d] : “, n, base);
while(n)
{
m=n%base;
digits[i]="0123456789abcdefghijklmnopqrstuvwxyz”[m];
n=n/base;
i++;
}
//Eliminate any leading zeroes
for(i–;i>=0;i–)
{
if(!flag && digits[i]!='0’)flag=1;
if(flag)printf("%c”,digits[i]);
}
}