malloc works with int but not with strings

Im a very new to C language. Im trying to learn about to memory allocation with the next examples. If I allocate memory for a integer like this: int* pint = (int*)malloc(sizeof(int)); if (pint == NULL) { printf("NULL pointer!"); } else { *pint = 5; printf("el valor es: %d", *pint); free(pint); } This show perfectly… Read More malloc works with int but not with strings

Why does assignment to int and float are not generating error whereas assignment to while does generate error?

Source: int = 33 float = 0.0 while = 33 Output: while = 33 ^ SyntaxError: invalid syntax Why does assignment to int and float are not generating error in python whereas assignment to while generates error? >Solution : while is a keyword. Keywords are essential parts of the language that cannot be used as… Read More Why does assignment to int and float are not generating error whereas assignment to while does generate error?

What happens when opeator= returns void rather than T&?

In operator overloading, the assignment operator is normally defined as follows: T& T::operator =(const T2& b); which returns T& as result. But I want to know what happens when we return void. For example, the assignment operator of std::atmoic<std::shared_ptr<T>> returns void: void operator=( std::shared_ptr<T> desired ) noexcept; as defined here and here. What happens in… Read More What happens when opeator= returns void rather than T&?