How to return local array in C++?

I would suggest std::vector<char>: std::vector<char> recvmsg() { std::vector<char> buffer(1024); //.. return buffer; } int main() { std::vector<char> reply = recvmsg(); } And then if you ever need char* in your code, then you can use &reply[0] anytime you want. For example, void f(const char* data, size_t size) {} f(&reply[0], reply.size()); And you’re done. That means, … Read more

How to specify multiple return types using type-hints

From the documentation class typing.Union Union type; Union[X, Y] means either X or Y. Hence the proper way to represent more than one return data type is from typing import Union def foo(client_id: str) -> Union[list,bool] But do note that typing is not enforced. Python continues to remain a dynamically-typed language. The annotation syntax has … Read more

New to programming: How to call a structure’s variables in a function and then update them? (C++) [closed]

Seems to me that you want this: #include <iostream> struct Point { float X; float Y; }; struct Line { Point Point1; Point Point2; float slope; float yInt; float lineLength; float Angle; }; Line getLine() { Line var; std::cout << “enter the first point:”; std::cout << “\nEnterX and Y coordinates separated by spaces:”; std::cin >> … Read more