4,579 questions
-5
votes
3
answers
99
views
How to fix printing declared function [duplicate]
I'm still new at functions and I tend to print the function which I don't know how to print the declared function. It prints "1" and not "John".
#include <iostream>
void ...
0
votes
0
answers
43
views
PHP foreach loops with references - wierd behaviour [duplicate]
Im currently developing a webpage and during that i wrote some code that looks similar to this:
$foo = ['bar1', 'bar2', "bar3"];
foreach($foo as $i => &$bar){
if($bar == "...
0
votes
2
answers
139
views
Why does this function not modify the original array when passed as a parameter?
#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 (...
2
votes
2
answers
96
views
Issues passing by reference with gcc. No issues when compiling with gcc
EDIT: Adding this to the top because it is critical information being missed. The FSCC_REGISTERS_INIT call does EXACTLY what it is supposed to do, which is fill the entire struct with '-1's. The ...
2
votes
4
answers
94
views
Iterating over an Array
I tried this block of code and it yields two different results
public class PassArrayToFunction {
public static void increase1(int[] arr){
for(int a: arr)
a += 1;
}
...
2
votes
3
answers
96
views
Pass "Slice" structs by value or by reference? [closed]
I have the following two structs. They are both "slices" in that they have a pointer to data and dimensions, but they do not "own" the data (they are not responsible for memory ...
0
votes
2
answers
52
views
Batch function get the value of variable pass by reference
In the below script, there is passed var1 by reference to myDosFunc, so it can change the value.
How can the value of the referenced variable be get within the function without having to pass the ...
2
votes
1
answer
29
views
Update items shown in two different views with their own controllers in flutter
I'm new to flutter, and I'm trying to build an application to organize a personal schedule.
I have two views, one for the confirmed events and the other for the non-confirmed ones.
Using calendar_view,...
1
vote
1
answer
54
views
Error in using call by reference with function to change the head of a singly linked list
I'm learning linked lists in C, and have come across an error when trying to add a value at beginning of a linked list using functions
#include<stdio.h>
#include<stdlib.h>
struct node{
...
2
votes
1
answer
70
views
How can I pass a file to a function and store the files' contents in an array?
How can I pass a file to a function and store the files' contents in an array?
I have an assignment for a beginner C++ class. The assignment (or at least the part I need help with) is to pass in 2 ...
0
votes
0
answers
49
views
Java Array behaving as call-by-reference only sometimes [duplicate]
I've encountered an interesting issue in Java - I don't know if it's a well known thing (I don't even know what to search for!).
Code:
public static void main(String[] args) {
String[] fruits = {&...
1
vote
1
answer
323
views
Why is my Angular signal effect not working?
The signal is created in ProductSidenavService:
@Injectable({
providedIn: 'root'
})
export class ProductSidenavService {
public productSidenavSignal = signal<ProductSidenavModel>( new ...
2
votes
3
answers
155
views
Why pass void pointer instead of custom type?
Setup
I'm taking over code from another person. I found a coding pattern that seems odd to me. This is for an embedded 32 bit PIC processor, in case that's relevant.
They have a custom typedef in a ...
0
votes
0
answers
24
views
SWIG function returning reference
I want to run SWIG on the following C++ structure :
struct TestAlias
{
TestAlias(double a1, double a2, double a3) : angle1(a1), angle2(a2), angle3(a3) {}
...
0
votes
3
answers
176
views
Incrementing int passed by reference C++ [closed]
int x = 0;
incrementX(&x);
x has unexpected results at this point
void incrementX(int* x)
{
// value in x stays 0
*x++;
// value increments each time 1,2,3 ...
*x+=1;
}
Why ...