Skip to main content
Filter by
Sorted by
Tagged with
1 vote
3 answers
237 views

The C23 standard says(6.7.7.4 #7): A declaration of a parameter as "array of type" shall be adjusted to "qualified pointer to type", where the type qualifiers (if any) are those ...
ALICEZzz's user avatar
  • 639
0 votes
1 answer
55 views

Learning about flows and the interface definition is this: interface Flow<out T>{ suspend fun collect(collector: FlowCollector<T>) } collect has no function parameter yet I'm allowed ...
Ken Kiarie's user avatar
0 votes
2 answers
185 views

#include <stdio.h> void modifyArray(int arr[]) { arr = (int[]){6, 7, 8, 9, 10}; // Trying to modify the array } int main() { int arr[] = {1, 2, 3, 4, 5}; modifyArray(arr); for (...
Alphin Thomas's user avatar
-3 votes
2 answers
164 views

Is it possible in C++ to use format specifiers in a custom function? Like as in the printf() statement, and how you can use e.g. '%d' to insert an int variable: printf("The number is %d", ...
user avatar
0 votes
0 answers
84 views

I'm trying to suppress compiler warnings for unused function parameters. I know of two methods: Using [[maybe_unused]] in C++17 or later: void foo([[maybe_unused]] int x) { // x is unused } ...
Radistal's user avatar
8 votes
3 answers
229 views

Suppose I have a function which takes some pointer parameters - some non-const, through which it may write, and some const through which it only reads. Example: void f(int * a, int const *b); Suppose ...
einpoklum's user avatar
  • 138k
-1 votes
3 answers
115 views

I have the following functions where processArray is a generic function that is used to process an array. A function is passed to it as a parameter so that each element can also be processed. template&...
mihails.kuzmins's user avatar
0 votes
0 answers
33 views

I want to have a function with infinite parameters but I don't want to declare them How do I do this? function func(){ for(let i = 0; i < params.length; i++){ console.log(param[i]); } }
Jerico's user avatar
  • 50
0 votes
0 answers
23 views

I want to allocate memory for a two-dimensional array of char in a separate function. I defined a double pointer in the main function, then I passed this pointer into my separate function alloc_arr(), ...
elo2cx's user avatar
  • 33
0 votes
3 answers
159 views

I want to write Breadth-First Search and Depth-First Search functions for a graph. But these functions should be able to take a function as a parameter so I can pass each node in the graph to the ...
NAMEGOESHERE's user avatar
3 votes
1 answer
93 views

Dear Experts my concept is the following: I have some structured data (in struct F_data), and I want to fit various function on this data (eg. parabola, hyperbola etc.). Therefore I have a base class (...
Tom Solid's user avatar
  • 2,531
0 votes
2 answers
345 views

protocol myProtocol {} func doSomething(with params: (some myProtocol)...) { // Implementation goes here } extension Int: myProtocol {} doSomething(with: 1, 2, 3) Compilation error at the func ...
Roman's user avatar
  • 1,520
1 vote
2 answers
66 views

I would like to pass an overloaded function as an argument for a variadic template function. I understand how to do it with one particular function (using static_cast). However, I am wondering if ...
MarkKwain's user avatar
0 votes
0 answers
31 views

I need to use the function capwords() from SGP in the way to get approach to use the value of default parameter special.words extended with my additional words. I.e. I need to do somthing like: ...
Sergey V.'s user avatar
  • 1,028
2 votes
3 answers
137 views

Consider: cbind("1" = 1:4) ## giving. 1 [1,] 1 [2,] 2 [3,] 3 [4,] 4 What I am trying to achieve is replacing "1" with a function that returns a character expression, e.g. ...
clp's user avatar
  • 1,702
3 votes
2 answers
149 views

When designing a function that expects a contiguous array in the form of a pointer, should one pass the array using A. a pointer and the array's size: void foo(int* arr, size_t size); Or B. a begin-...
JensB's user avatar
  • 959
1 vote
1 answer
73 views

If I write something as follows: int f(char x, const int (*g) (const char x)) { return g(x); } does the first const say effectively what I think it says, namely basically that the programmer can'...
Sasha's user avatar
  • 371
1 vote
1 answer
107 views

My goal is to create an API interface that looks like that this: struct myAB{ int a,b; }; void function(myAB ab) {} ... function({.a = 1, .b = 3}); The above works just fine. But if I want struct ...
dada_dave's user avatar
  • 493
1 vote
1 answer
59 views

I have the following code: function Main{ $param1 = @" aaa bbb ccc "@ Test -Param1 $param1 } function Test { param ( [Parameter(Mandatory)][string]$Param1 ) ...
Fajela Tajkiya's user avatar
0 votes
2 answers
179 views

I have a 2D array of strings char* d2Array[valueA][valueB]. This works fine, I am able to fill it with strings and access them. There is an issue when passing it to a function. You need to specify the ...
user avatar
0 votes
2 answers
684 views

That sounds kind of complex. The idea here is to write the method "defaultMethod". It receives a function and an object. If the function is a simple add: function add(a,b) { return a+b;}; ...
Bipe's user avatar
  • 37
0 votes
1 answer
332 views

I am new to coding and started off with C. I am trying to recreate the famous Snake game and currently using the betty style of coding. Apparently global variables are not allowed and so far What I ...
Johnny's user avatar
  • 103
2 votes
1 answer
234 views

I have a class object entity which gobbles up a string and shoves it into it's member on construction (for the sake of this argument this could be any old member function). Now I can do this in at ...
glades's user avatar
  • 5,392
0 votes
1 answer
48 views

I have this function, and I want to make the table '[SEJ_Reservation]' as a parameter to the function, to be able to use the function with another table, the function as below : CREATE FUNCTION [dbo].[...
Khaled Nasser's user avatar
1 vote
2 answers
96 views

What I'm looking for is to have a function with infinite number of parameters and each parameter type is based on if its index is even or odd. A contrived example: flow(isMachineReady(), 'and', ...
hassan salehi's user avatar
11 votes
3 answers
957 views

Is it valid, according to ISO C (any version), to specify a zero-sized array parameter? The standard seems ambiguous. While it's clear that zero-sized arrays are invalid, array function parameters ...
alx - recommends codidact's user avatar
11 votes
3 answers
15k views

I have this drawer I learned to make on youtube https://www.youtube.com/watch?v=JLICaBEiJS0&list=PLQkwcJG4YTCSpJ2NLhDTHhi6XBNfk9WiC&index=31 Philipp Lackner I want to add the drawer to my app ...
Dolev Dublon's user avatar
1 vote
1 answer
43 views

I am trying to using C to work with files with different extensions. So this is the code that I have written. #include <stdio.h> #include <windows.h> #include <unistd.h> #include <...
Sammy1410's user avatar
0 votes
0 answers
140 views

To start: this question is already kind of resolved for me. But the discussion might be interesting. I like code so let's look at this function: fun foo(path: Path) { val absPath = path....
Stefan's user avatar
  • 1
1 vote
3 answers
1k views

I would like to know the difference between assigning an array item to variable and accessing directly to it. As I show in the code below, #1 hits the possibly null error, but #2 and #3 doesn't. Those ...
Leech's user avatar
  • 582
2 votes
1 answer
169 views

I have inherited some code like this public static function instanciateRepository( $repositoryClass, ... ) { ... new $repositoryClass( ... ); } Where $repositoryClass is a class type ...
Anton Duzenko's user avatar
3 votes
2 answers
701 views

I have a union type of an Array of various specific lengths: [ number ] | [ number, number ] | [ number, number, number, number ] As you can see, there are requirements for an array with one element, ...
DubiousMaster's user avatar
0 votes
1 answer
102 views

I have a an equation that i want to use as an argument in my function, the catch is i want to have it within my function without defining any of its variables. The idea is once have it inside my ...
hghebrem's user avatar
2 votes
1 answer
468 views

I have a list of inputs over which I loop using purrr::map. Using a tweaked version of purrr::possibly (for more details see here) Applying this version of "possibly" to my main function, I'...
Rasul89's user avatar
  • 598
0 votes
1 answer
230 views

I am learning C++ using the resources listed here. In particular, I came to know that copy initialization is used when passing arguments to function parameters(by value) etc. For example, from decl....
user avatar
0 votes
1 answer
98 views

I'm trying to pass a class object as an argument to a global function. Here's the function: def CreatePlayers(p1_Name, p2_Name, cardDeck): #Function to Create Players #Takes 3 variables: Names of ...
Grimmace_23's user avatar
-1 votes
3 answers
65 views

Do javaScript accept multiple strings as a function parameter? function name(Haydon Lyson){ //code } will it be accepted? If not then how can we pass multiple strings as function parameter.
Ivanovich's user avatar
0 votes
2 answers
761 views

I'm trying to write a function that will accept 2 parameters i.e key and subkey and return one of the properties of that nested object. I have successfully written the type for function but cannot ...
Kunal Jain's user avatar
0 votes
1 answer
901 views

I've written a custom function that does a number of checks and throws a different error when a check fails. Below is a simple example function that takes a data.frame and a column name and simply ...
Rasul89's user avatar
  • 598
-2 votes
2 answers
3k views

Task: write a function to calculate the area of a square, rectangle, circle. My code is right. IDK why I am getting this error complete error #include<stdio.h> #include<math.h> int square()...
numextrix's user avatar
0 votes
1 answer
418 views

I have 2 files. One of them is "http" folder for requests, the other one is React Component. I have a problem when I want to change the form and upload a profile photo. Changing form is ...
Rahil Ali's user avatar
  • 386
0 votes
1 answer
27 views

This is the code I want to write interface InputField{ formHeading:string, isText:boolean, fields:any[] } interface InfoField{ formHeading:string, isText:boolean, textData:...
Nitin Kumar Pandey's user avatar
0 votes
1 answer
174 views

Assum I have some pure C code like this. It is not the real code, just for an example. struct Param { struct InParam { int a; int b; } in; struct OutParam { int *c; } out; }; ...
Xingx1's user avatar
  • 127
-1 votes
2 answers
770 views

I am new to C++ and I am writing pseudo code here: void fn(a) {} fn(b) It is correct to assume that in the function body fn what happens is this assignment `a = b` I know we can pass the reference/...
Joji's user avatar
  • 5,856
0 votes
1 answer
4k views

Is there a way to pass an empty std::span<int> to a function? I have a function like below: bool func( const std::vector<int>& indices ) { if ( !indices.empty( ) ) { /* ...
digito_evo's user avatar
  • 3,735
1 vote
1 answer
416 views

I've to call a function with parametres but i didn't find a correct solution for my problem. The NavigateTo should pass a String value to my index to switch it and navigate to the correct component(no ...
Matteo Pagliarello's user avatar
2 votes
1 answer
95 views

I have an input in html and want to put the text of the input into an object on JS and display it on a tag on html as a result. Because I didnt wanted to simplify the code, i tried to create a ...
youngmago's user avatar
2 votes
2 answers
101 views

Comparing this 2 codes: void foo(int rows, int cols, int **ar) { printf("%d\n", ar[rows - 1][cols - 1]); } and void foo(int rows, int cols, int ar[rows][cols]) { printf("%d\n",...
milanHrabos's user avatar
  • 2,017
2 votes
2 answers
3k views

Using TypeScript 4.4.3, I want to be able to explicitly type function parameters to a function that returns a generic. TypeScript is ignoring the types for the parameters to functions that use ...
nstuyvesant's user avatar
  • 1,536
4 votes
4 answers
5k views

Is it possible to have a conidial required argument type based on the first argument type: type ConditionalRequiredArg<T, P> = T extends string ? P | undefined : P; function func<T, P>(...
cyrus-d's user avatar
  • 843

1
2 3 4 5
7