Category "return-value"

Returning dynamic memory inside a struct in C

Hi I have the following struct typedef struct mystruct_s { int* array; } mystruct; and I want to create a function that initializes it. I have two ways of

A question about returning local pointer variable in function

I know the variables in function are using stack space. When function exit, the space are freed. That's why we should declare the pointer variable as static in

Trying to convert text into hex by calling a function within my batch file, but the hex code never gets returned to the Main batch function

@echo off goto :main :strg2hex setlocal EnableDelayedExpansion rem Store the string in chr.tmp file set /P "=%~1" < NUL > chr.tmp rem Create zero.tm

What is std::expected in C++?

In one of the most respected stackoverflow answer I found an example of std::expected template class usages: What are coroutines in C++20? At the same time I ca

Return map like 'ok' in Golang on normal functions

In Go, the following works (note one use of the map has one return, the other has two returns) package main import "fmt" var someMap = map[string]string { "s

Multiple values in single-value context

Due to error handling in Go, I often end up with multiple values functions. So far, the way I have managed this has been very messy and I am looking for best pr

Why would return parameters be named?

What benefits arise from naming a function's return parameter(s)? func namedReturn(i int) (ret int) { ret = i i += 2 return } func anonReturn(i in