Tagged Questions
-1
votes
3answers
32 views
how to check for the 1st element and last element in array c++
Compute the smoothed array by doing this: Each value smooth[N] is
the average of three values: signal[N-1], signal[N], and signal[N+1].
For the first element of
smooth, average the first two ...
-3
votes
1answer
37 views
Function that returns average
I have to write a function called smoothArray() that takes the average of values of the first two elements in the first array.
Here is the assignment
Compute the smoothed array by doing this: Each ...
1
vote
1answer
13 views
AS3 - Call function with forEach
Flash throw this error in the Output panel:
ReferenceError: Error #1069: Property alpha not found on String and there is no default value.
The problematic code:
var mcs:Array = new Array();
...
-1
votes
1answer
27 views
Calling functions from within functions (with arguments) in PHP
I’m building a system that captures info from a POST method and adds them into a PHP $_SESSION. The basic logic I want to follow is:
Check the method and call the relevant function
Check if ...
0
votes
2answers
26 views
C Pointer/reference to array of structures from within function
I got a problem with making a custom function on top of the FastLed library for Arduino.
The array of leds, structures called CRGB needs to be altered from inside the function drawGradient to set the ...
1
vote
2answers
52 views
Check if string contains spam words
Am trying to implement a little bit of code found on stack overflow which covers a spam words filter. When i just type a spam word the function works however when I type in a bunch of text before the ...
0
votes
1answer
32 views
Stuck at an assignment - Confused as to what to do
(Language is processing)
Hey, I have an assignment that I don't really understand. This is part 2 of another assignment, where I had to make a function called drawButton, that uses an array as ...
0
votes
2answers
51 views
Can Ada functions return arrays?
I read somewhere that Ada allows a function only to return a single item. Since an array can hold multiple items does this mean that I can return the array as a whole or must I return only a single ...
-2
votes
0answers
20 views
How to work with an existing global array from a custom function in C++? [on hold]
I am a beginner in (Visual) C++. I want to make a program that reads all text files from one folder, detects the youngest file, then reads its content, extracts three lines as parameters. It also ...
3
votes
1answer
36 views
Passing an array name to a function, then populating it
I would like to call a function that takes data and then populates an array I name in one of the function parameters. Example of what I'm looking for:
function readSaveFile(saveFileName, arrayName)
...
1
vote
4answers
43 views
Simplify a working function to replace specific words?
I have a function to shorten certain words when the label wraps (to adjust to various resolutions). My function is working, but I think it can be simplified...just I'm not sure how. As I add more ...
0
votes
4answers
56 views
Returning an address of a character from a function in C++
I'm trying to write a program that will take a string as an input and a character to find in that string . A function should then return the address of that particular character . The logic seems to ...
-2
votes
0answers
15 views
Add Animation for Score Changes
I am trying to add an animation to my score so that every time the score changes an animation will happen, however I'm not sure how to do this.
The problem is this is not my code but an assignment ...
-4
votes
1answer
26 views
Why are the results of array_walk() function so crazy? [closed]
Why the following code returns second character of the array values?
$name = array("John","Frank","Peter");
function myFunction($name) {
echo $name[1];
}
array_walk($name,"myFunction"); //output ore
...
0
votes
0answers
12 views
range-based for loop in a function [duplicate]
I programmed in C for a while and now I'm new to C++. I have to replace the for-loops in a C-Programm with the range-based for loops of C++11.
This is the actual code:
void sort1(int num[], int ...
0
votes
0answers
49 views
Want to put comma separated values from 1 column to another or in the same column
Here, All the Data is coming data from api. Consider, there is a task which can assigned to one or more than one users - TASK_TABLE is given below:
TASK_ID,TASK_NAME,ASSIGNED_TO,CREATED_DATE,...etc. ...
0
votes
2answers
26 views
PHP-cURL Adding entry to an array in a function not working
I can echo the response i get just fine in the function request_callback so I thought it trivial to just save the response into an array associative_array[], however this yields just single entries, ...
2
votes
2answers
35 views
Good practice for referencing returned array values
This is something I haven't seen before but it appears to be supported and it does work, referencing the returned array key directly after the providing function is called. BUT... is this good ...
2
votes
1answer
38 views
How to display function value?
I am using this function and declare display_error(),
but error display on my screen
"Warning: Invalid argument supplied for foreach()"
help with us.
function display_error($nerrors = '')
{
...
0
votes
3answers
34 views
Python: How do you display/loop a sequence of numbers from an array using functions and loops? Visual Metronome
Ok, so new to coding and I've managed to piece this together from PTHW by Zed Shaw, Google, and some existing help on here.
I can't seem to figure out how to loop through the sequence of numbers in ...
0
votes
1answer
80 views
Return value of an array for each item in a list
I'm still quite new to writing functions and PHP so please excuse me if this is easy. Let me provide a little background...
I have built an e-commerce site using MarketPress by WPMUDev and trying to ...
-1
votes
3answers
36 views
Passing multiple values to a function PHP
i have a function looks like this:
function foo($value)
{
echo "print: '".$value."' "
}
I want to pass an array as $value because i need to print a variable number of values. How can i pass ...
-1
votes
2answers
57 views
pass 2d array to a function in c++
I am trying to pass a 2d array to a function in c++. The problem is that its dimension is not universal constant. I take the dimension as an input from the user and then try to pass the array. Here is ...
-5
votes
1answer
70 views
Stuck on program to design functions with arrays [on hold]
I'm trying to get this program to work but I can't and I've already searched at least 5 websites.
These are the instructions:
Design a program that will allow a user to Input a list of your ...
0
votes
1answer
50 views
C++ pass an array of bitfields by reference
I'm trying put my map render (console, ASCII) to one function, but it don't compile.
It should be look like this:
struct tiles {
unsigned is_visible : 1;
//...
} tile[y][x];
void ...
0
votes
0answers
12 views
Creating an array to print the numbers generated by a formula
from pylab import *
import numpy as np
a = 0.001
b = 0.022
vals = loadtxt("Values.txt", unpack = True, skiprows = 1)
one = a
two = b
def result(one,two):
a = one
b = two
i = 0.003
...
-2
votes
2answers
29 views
Value is not an array nor pointer nor vector
I'm working on some C homework for class and I've been running into issues using arrays. Here is a sample of one of my functions that's having an error.
void multiply(int a, int size)
{
int i;
...
0
votes
1answer
21 views
Implementing a closure to “carry” an array index to another array? [duplicate]
Based on the answer I received here, it seems I need a closure to get this code working correctly. Unfortunately, despite the links provided, I am still confused as to how a closure should be ...
1
vote
1answer
55 views
Passing pointer of char array to function
Below is my function which takes a char array of size 2, passes it to a function and the function should return the same 2 chars back (its a bit of a convoluted process as it's talking to a hardware ...
0
votes
1answer
74 views
Function to print an array [duplicate]
Could anyone explain why this doesn't print correctly?
This is basic program with functions to read and print an array. All seems to be according to what I read...
I'm new and can't seem to make ...
0
votes
1answer
15 views
PHP Help to simplify an IF statement when retrieving results from a function
Let's say i have this function that seeks for a value inside a bidimensional array:
function findValueBi($array, $field, $value, $returnfield)
{
foreach($array as $key => $product)
{
...
0
votes
1answer
37 views
Trying to figure out arrays as function parameters
I've just started learning about arrays as function parameters and I just cant seem to wrap my head around it. I'm trying to create a function that asks a user to enter the values of the matrix and ...
0
votes
2answers
42 views
I want to print the largest value row which has 4 5 columns in c++
I want to print the largest value row which has 4 5 columns in c++. I have two classes one is cpu and other one is process. How can I send a value to cpu from process and after updating that value ...
0
votes
1answer
23 views
Is it possible to use the result of a PHP function directly as an array?
Function func() returns an array
<?php echo func($arg)[0] ?>
So this code must work, but it isn't.
Why? And how I can do it without assigning the result of the function to a variable?
1
vote
1answer
46 views
Iterating through c array through function
So I'm trying to figure out a way to iterate though an array passed into a function without knowing the size. I run into infinite loops with my code because the arrays are not NULL terminated. Since ...
0
votes
2answers
57 views
How do I make this javascript more eloquent without using objects and switch statements?
I don't want to type out every possible price combination but I've been searching for a long time and can't find a better way:
var selection = new Array (4);
selection[0] = new Array ('$210' 'etc', ...
0
votes
1answer
27 views
Need help inserting values from sql_fetch_array into a function
pardon me if this is a noob question.
I am trying to call a public function delete() from a .php file in a folder.
The public function delete() is in fileA.php
I created another file: fileB.php ...
-2
votes
1answer
36 views
Why is this function that makes an array changing another variable?
I have a function here
char ** makeArray(int count)
{
char **array[count];
return array[count];
}
that takes in the number of tokens from an array then returns an array with the correct ...
-3
votes
2answers
54 views
How to avoid writing thousands of variables in javascript? [closed]
(I'm a beginner). If I wanted to set up a system for asking questions and returning user-inputted answers using if statements and variables, there will be a large amount of potential combinations of ...
0
votes
2answers
41 views
Can a bash function access and manipulate its script's command-line arguments?
I am trying to tidy up some bash code. I have a bunch of lines like the example below that set variables, unless set already, using the command-line arguments given to the script.
[[ -z "${myvar1}" ...
0
votes
2answers
44 views
How to add the numeric values of properties of a nested array?
I'm trying to figure out how to make a function that adds the values of the elements chosen by the user and be able to display the results via prompt and console.log. Also, I'm wondering if there is a ...
1
vote
2answers
49 views
Move array item to another array on click
I have two kinds of arrays going on which are
var arrayAdmins = [{"firstName": "Admin", "lastName": "User", "email": "[email protected]","password": "admin"}];
var aBlocked = [{"firstName": "Blocked", ...
1
vote
2answers
26 views
Object is changed in Python
I am newbie to python and OOP concepts and i am unable to understand certain things,like why some function change the original object and some doesn't. To understand it better, I have put my confusion ...
0
votes
4answers
40 views
Generic methods with an array parameter?
I want to write a generic method that prints an array of any type that I send to it. I tried
public static <T> void printArr(T[] a)
{
int length = a.length;
for(int i = 0; i < ...
-1
votes
1answer
44 views
How to fix a calling function with array argument in it
what I need to write to fix that
#include <string>
#include <iostream>
using namespace std;
struct Date
{
int month, day, year;
};
struct Students
{
string name;
Date bd;
int ...
0
votes
1answer
22 views
Passing array within functions - form validation & display error
I have 3 functions (cut down version of what I am trying to do). It seems when the function returns the array, it only returns the last value (which is null in my case) and loses the values appended ...
-4
votes
4answers
161 views
How to make a function take in an array of numbers and give the ones less than 70?
"write a JavaScript function that is called countFailing that takes in an array of grades and returns the number of failing grades (grades below 70).
The function must take in one parameter that will ...
0
votes
1answer
47 views
Passing array of structures to a function in different file in C
I need to pass an array of structures defined in a file "file1.c" to a function, lets say "myFunc()", defined in another file "file2.c". The thing is that I don't know how to set the prototype of ...
-1
votes
3answers
28 views
PHP cannot convert an array using list if the array is returned by a function?
This one is stumping me. I'm trying to figure out why this doesn't work. I have a function that returns an array. I want to use list to put that array into variables. It doesn't seem to be working. ...
0
votes
1answer
43 views
Returning array address from function [duplicate]
I was trying to pass the array address from the function to the main function that's happening perfectly. But when I dereference the address in main(), I am getting junk values. I am guessing that the ...