argument-passing

C++ member function pointer with different arguments - or is this bad anyway?

天大地大妈咪最大 提交于 2020-01-01 16:26:59
问题 Even though I fear that you will tell me that this topic was covered several time, I dare to ask it, since I was not able to generate a solution. Probably I was just looking for the wrong thing... Assume that I have a function which receives a "mode" from some external function. Depending on the mode, the function will call different member functions of the same object. This works well for me with member function without any argument, but I did not find out how to extend it to members with

Passing multi-dimensional arrays in C

情到浓时终转凉″ 提交于 2019-12-30 10:58:09
问题 I am currently trying to learn C and I have come to a problem that I've been unable to solve. Consider: #include <stdio.h> #include <stdlib.h> #include <string.h> #define ELEMENTS 5 void make(char **array, int *array_size) { int i; char *t = "Hello, World!"; array = malloc(ELEMENTS * sizeof(char *)); for (i = 0; i < ELEMENTS; ++i) { array[i] = malloc(strlen(t) + 1 * sizeof(char)); array[i] = strdup(t); } } int main(int argc, char **argv) { char **array; int size; int i; make(array, &size);

How do I globally change a variable value within function in lisp

安稳与你 提交于 2019-12-29 07:59:46
问题 I would like to know if there is any way to mimic C behaviour with pointers in LISP. In C if you change a value of a variable, that pointer is pointing to, it has a global effect (i.e. the value will be changed outside the function too). So if I had (defun mutate ( a ) (some-magic-function a 5) ) a would turn to 5 after calling mutate, no matter what it was before. I know it is possible (much of as a side effect) with elements with lists In common-lisp, how do I modify part of a list

Parsing/passing command line arguments to a bash script - what is the difference between “$@” and “$*”?

女生的网名这么多〃 提交于 2019-12-28 16:08:07
问题 I am using a bash script to call and execute a .jar file from any location without having to constantly enter its explicit path. The .jar requires additional variable parameters to be specified at execution, and as these can be anything, they cannot be hard coded into the script. There are 3 variables in total, the first specifies 1 of 2 actions that the .jar is to make, the second specifies a target file to enact this action on and the third specifies the name of a file that the action is to

List as a function argument - modifications discarded

北慕城南 提交于 2019-12-25 06:54:20
问题 I have a following code def hidePasswords(L, password): for elem in L: if elem == password: elem = "*"*len(password) return L print(hidePasswords(["test","test1","test8"],"test")) It returns ['test', 'test1', 'test8'] instead of ['****', 'test1', 'test8'] . When I change my function to def hidePasswords(L, password): temp = [] for elem in L: if elem == password: elem = "*"*len(password) temp.append(elem) return temp it works correctly. Why does Python behaves in such a way? I perfectly

passing arguments to functions in php

99封情书 提交于 2019-12-25 01:43:59
问题 I have some php code that is pretty much being duplicated save for some minor variable naming differences. How can I turn this into a reusable function where I can pass arguments thru? This is the code which I am using twice. The second one is the same except all references of "affiliate" is changed to "social". <?php $affiliate = wp_list_bookmarks( array( 'categorize' => 0, 'category' => '7', 'title_li' => '', 'orderby' => 'rating', 'show_images' => 0, 'echo' => 0 ) ); preg_match_all( '/<li>

Run-time parameters in gcc (inverse va_args/varargs)

99封情书 提交于 2019-12-24 21:22:20
问题 I'm trying to make some improvements to a interpreter for microcontrollers that I'm working on. For executing built-in functions I currently have something like this (albeit a bit faster): function executeBuiltin(functionName, functionArgs) { if (functionName=="foo") foo(getIntFromArg(functionArgs[0])); if (functionName=="bar") bar(getIntFromArg(functionArgs[0]),getBoolFromArg(functionArgs[1]),getFloatFromArg(functionArgs[2])); if (functionName=="baz") baz(); ... } But it is for an embedded

rake task with multiple parameters - I got stuck

我怕爱的太早我们不能终老 提交于 2019-12-24 19:25:41
问题 The rake task itself: desc "This task creates a new user" task :create_user, [:email, :password] => :environment do |t, args| trole = Role.find_by_name('translator') User.create( :email => args.email, :password => args.password, :password_confirmation => args.password, :role_id => trole.id) end The call: rake create_user[user@host.com,password] The output: rake aborted! Don't know how to build task 'create_user' I really got stuck. All the advices I've found, even here, on StackOverflow,

Pass Content To Function of Another Module in Python

不想你离开。 提交于 2019-12-24 15:19:00
问题 I am using SAX Parser. I am trying to send the 'content' I retrieved using below code: After checking the startElement and endElement, I have the below code: def characters(self, content): text = format.formatter(content) this format.formatter is expected to read this data that I sent as 'content' for any processing like removing junk characters etc and return it. I do that by using string.replace function: remArticles = {' ! ':'', ' $ ':''} for line in content: for i in remArticles: line=

pass argument to function passed as argument to jQuery function

匆匆过客 提交于 2019-12-24 14:15:45
问题 Passing function name as a parameter to another function doesn't seem to work for me. I've tried every variation from every article I can find. Currently, I have this in one js file: function callThisPlease (testIt){ alert(testIt); } $(document).ready(function () { $.fn.pleaseCallTheOtherFunction('callThisPlease'); }); I have this in another: $(document).ready(function () { $.fn.pleaseCallTheOtherFunction = function(functionName){ window[functionName].apply('works'); } }); chrome console says